├── AlphaHexValues.txt ├── AnimatedButton ├── GuiButtonAnimatedExample.java └── README.md ├── AnimatedResourceLocation ├── AnimatedResourceLocation.java └── README.md ├── CPSMod ├── ModCPS.java └── README.md ├── FakeUtils ├── FakeChunkProvider.java ├── FakeNetworkManager.java ├── FakeNetworkPlayerInfo.java ├── FakePlayer.java ├── FakeSaveHandler.java ├── FakeWorld.java ├── FakeWorldProvider.java ├── README.md └── _ExampleGui.java ├── GuiChatComponents ├── GuiExampleChatComponent.java └── README.md ├── GuiCheckBox ├── GuiCheckBox.java └── README.md ├── GuiScrollExample ├── GuiTestList.java ├── README.md └── ScrollListTest.java ├── JarLoader ├── GenericJarLoader │ ├── res │ │ └── plugins │ │ │ └── ExamplePlugin.jar │ └── src │ │ └── org │ │ └── golde │ │ └── genericjarloader │ │ ├── Main.java │ │ ├── PluginLoader.java │ │ └── api │ │ ├── Plugin.java │ │ ├── PluginDescriptionFile.java │ │ └── PluginException.java ├── GenericJarLoaderExamplePlugin │ ├── plugin.json │ └── src │ │ └── org │ │ └── golde │ │ └── genericjarloader │ │ └── example │ │ └── ExamplePlugin.java ├── README.md └── lib │ ├── gson │ ├── gson-2.8.6-javadoc.jar │ ├── gson-2.8.6-sources.jar │ └── gson-2.8.6.jar │ └── lombok │ ├── lombok-1.18.20-javadoc.jar │ ├── lombok-1.18.20-sources.jar │ └── lombok-1.18.20.jar ├── NBTColorizer └── NBTColorizer.java ├── README.md ├── SessionChanger ├── README.md └── SessionChanger.java ├── SimpleModToggleGui ├── GuiCheckBox.java ├── GuiModToggle.java ├── ModEntry.java ├── README.md ├── ScrollListModToggle.java └── screenshot.png ├── Sounds ├── README.md ├── SoundPrinter.java └── Sounds.java └── UrlTextureUtil ├── ModUrlImageTest.java ├── README.md └── UrlTextureUtil.java /AlphaHexValues.txt: -------------------------------------------------------------------------------- 1 | 100% — FF 2 | 99% — FC 3 | 98% — FA 4 | 97% — F7 5 | 96% — F5 6 | 95% — F2 7 | 94% — F0 8 | 93% — ED 9 | 92% — EB 10 | 91% — E8 11 | 90% — E6 12 | 89% — E3 13 | 88% — E0 14 | 87% — DE 15 | 86% — DB 16 | 85% — D9 17 | 84% — D6 18 | 83% — D4 19 | 82% — D1 20 | 81% — CF 21 | 80% — CC 22 | 79% — C9 23 | 78% — C7 24 | 77% — C4 25 | 76% — C2 26 | 75% — BF 27 | 74% — BD 28 | 73% — BA 29 | 72% — B8 30 | 71% — B5 31 | 70% — B3 32 | 69% — B0 33 | 68% — AD 34 | 67% — AB 35 | 66% — A8 36 | 65% — A6 37 | 64% — A3 38 | 63% — A1 39 | 62% — 9E 40 | 61% — 9C 41 | 60% — 99 42 | 59% — 96 43 | 58% — 94 44 | 57% — 91 45 | 56% — 8F 46 | 55% — 8C 47 | 54% — 8A 48 | 53% — 87 49 | 52% — 85 50 | 51% — 82 51 | 50% — 80 52 | 49% — 7D 53 | 48% — 7A 54 | 47% — 78 55 | 46% — 75 56 | 45% — 73 57 | 44% — 70 58 | 43% — 6E 59 | 42% — 6B 60 | 41% — 69 61 | 40% — 66 62 | 39% — 63 63 | 38% — 61 64 | 37% — 5E 65 | 36% — 5C 66 | 35% — 59 67 | 34% — 57 68 | 33% — 54 69 | 32% — 52 70 | 31% — 4F 71 | 30% — 4D 72 | 29% — 4A 73 | 28% — 47 74 | 27% — 45 75 | 26% — 42 76 | 25% — 40 77 | 24% — 3D 78 | 23% — 3B 79 | 22% — 38 80 | 21% — 36 81 | 20% — 33 82 | 19% — 30 83 | 18% — 2E 84 | 17% — 2B 85 | 16% — 29 86 | 15% — 26 87 | 14% — 24 88 | 13% — 21 89 | 12% — 1F 90 | 11% — 1C 91 | 10% — 1A 92 | 9% — 17 93 | 8% — 14 94 | 7% — 12 95 | 6% — 0F 96 | 5% — 0D 97 | 4% — 0A 98 | 3% — 08 99 | 2% — 05 100 | 1% — 03 101 | 0% — 00 102 | -------------------------------------------------------------------------------- /AnimatedButton/GuiButtonAnimatedExample.java: -------------------------------------------------------------------------------- 1 | package clientname.gui; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.FontRenderer; 5 | import net.minecraft.client.gui.GuiButton; 6 | import net.minecraft.client.renderer.GlStateManager; 7 | 8 | public class GuiButtonAnimatedExample extends GuiButton { 9 | 10 | //default constructors 11 | public GuiButtonAnimatedExample(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText) { 12 | super(buttonId, x, y, widthIn, heightIn, buttonText); 13 | } 14 | 15 | public GuiButtonAnimatedExample(int buttonId, int x, int y, String buttonText) { 16 | super(buttonId, x, y, buttonText); 17 | } 18 | 19 | //this stores the height of the animated rectangle we are drawing 20 | int animatedHeight = 0; 21 | 22 | @Override 23 | public void drawButton(Minecraft mc, int mouseX, int mouseY) 24 | { 25 | if (this.visible) 26 | { 27 | FontRenderer fontrenderer = mc.fontRendererObj; 28 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 29 | this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; 30 | 31 | //I am drawing the button as a rectangle, so I am not using any textures. 32 | 33 | /* 34 | * If we are hovered, we increese animatedHeight by one every frame. 35 | * Once we reach a greater height then the buttons height, we set it to the buttons height 36 | * 37 | * When we are not hovering, we decreese the animatedHeight variable until its at 0 38 | * if it goes greater then 0, we set it to 0. 39 | */ 40 | if(this.hovered) { 41 | animatedHeight++; 42 | if(animatedHeight > this.height) { 43 | animatedHeight = height; 44 | } 45 | } 46 | else { 47 | animatedHeight--; 48 | if(animatedHeight < 0) { 49 | animatedHeight = 0; 50 | } 51 | } 52 | 53 | //normal rectangle 54 | this.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0xFFFF0000); 55 | 56 | //animated one 57 | this.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.animatedHeight, 0xFF00FF00); 58 | 59 | //default stuff from GuiButton.java 60 | this.mouseDragged(mc, mouseX, mouseY); 61 | int j = 14737632; 62 | 63 | if (!this.enabled) 64 | { 65 | j = 10526880; 66 | } 67 | else if (this.hovered) 68 | { 69 | j = 16777120; 70 | } 71 | this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, j); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /AnimatedButton/README.md: -------------------------------------------------------------------------------- 1 | # Animated Button 2 | A lot of people wanted to know how to make a animated button, so here is a very quick and dirty example 3 | 4 | ## How to use 5 | ```java 6 | //this.buttonList.add(new GuiButtonAnimatedExample(id, x, y, text)); 7 | //this.buttonList.add(new GuiButtonAnimatedExample(id, x, y, width, height, text)); 8 | this.buttonList.add(new GuiButtonAnimatedExample(33, 200, 200, "Hello World")); 9 | ``` -------------------------------------------------------------------------------- /AnimatedResourceLocation/AnimatedResourceLocation.java: -------------------------------------------------------------------------------- 1 | public class AnimatedResourceLocation { 2 | 3 | private final String folder; 4 | private final int frames; 5 | private final int fpt; 6 | 7 | private int currentTick = 0; 8 | private int currentFrame = 0; 9 | 10 | private ResourceLocation[] textures; 11 | 12 | public AnimatedResourceLocation(String folder, int frames, int fpt) { 13 | this.folder = folder; 14 | this.frames = frames; 15 | this.fpt = fpt; 16 | textures = new ResourceLocation[frames]; 17 | 18 | for(int i = 0; i < frames; i++) { 19 | textures[i] = new ResourceLocation(folder + "/" + i + ".png"); 20 | } 21 | 22 | } 23 | 24 | public ResourceLocation getTexture() { 25 | return textures[currentFrame]; 26 | } 27 | 28 | public void update() { 29 | if(currentTick > fpt) { 30 | currentTick = 0; 31 | currentFrame++; 32 | if(currentFrame > textures.length - 1) { 33 | currentFrame = 0; 34 | } 35 | } 36 | currentTick++; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /AnimatedResourceLocation/README.md: -------------------------------------------------------------------------------- 1 | # AnimatedResourceLocation 2 | This provided the ability to animate textures with out using Minecrafts (shitty) animated textures that don't work in many places. 3 | 4 | ## How to use 5 | 1) Split your gif up into its frames. 6 | 2) Name them 0.png through n.png -- n being the number of frames 7 | 3) Create a new AnimationResourceLocation(folder path, how many frames, frames per tick) 8 | 4) call the update function, and the render function 9 | 5) bind the texture with getTexture() 10 | 6) Draw it on the screen 11 | -------------------------------------------------------------------------------- /CPSMod/ModCPS.java: -------------------------------------------------------------------------------- 1 | package clientname.mods.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.lwjgl.input.Mouse; 7 | 8 | import clientname.gui.hud.ScreenPosition; 9 | import clientname.mods.ModDraggable; 10 | 11 | public class ModCPS extends ModDraggable { 12 | 13 | private List clicks = new ArrayList(); 14 | private boolean wasPressed; 15 | private long lastPress; 16 | 17 | @Override 18 | public int getHeight() { 19 | return font.FONT_HEIGHT; 20 | } 21 | 22 | @Override 23 | public int getWidth() { 24 | return font.getStringWidth("CPS: 00"); 25 | } 26 | 27 | @Override 28 | public void render(ScreenPosition pos) { 29 | final boolean pressed = Mouse.isButtonDown(0); 30 | if (pressed != this.wasPressed) { 31 | this.wasPressed = pressed; 32 | this.lastPress = System.currentTimeMillis(); 33 | if (pressed) { 34 | this.clicks.add(this.lastPress); 35 | } 36 | } 37 | final int cps = this.getCPS(); 38 | font.drawString("CPS: " + cps, pos.getAbsoluteX(), pos.getAbsoluteY(), -1); 39 | } 40 | 41 | private int getCPS() { 42 | final long time = System.currentTimeMillis(); 43 | this.clicks.removeIf(aLong -> aLong + 1000L < time); 44 | return this.clicks.size(); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /CPSMod/README.md: -------------------------------------------------------------------------------- 1 | # CPS Mod 2 | Very simple Clicks Per second mod. It looks ugly bit is functional. Adapt to your needs :P -------------------------------------------------------------------------------- /FakeUtils/FakeChunkProvider.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import java.util.List; 4 | 5 | import net.minecraft.entity.EnumCreatureType; 6 | import net.minecraft.util.BlockPos; 7 | import net.minecraft.util.IProgressUpdate; 8 | import net.minecraft.world.World; 9 | import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; 10 | import net.minecraft.world.chunk.Chunk; 11 | import net.minecraft.world.chunk.IChunkProvider; 12 | 13 | public class FakeChunkProvider implements IChunkProvider { 14 | 15 | @Override 16 | public boolean chunkExists(int x, int z) { 17 | return false; 18 | } 19 | 20 | @Override 21 | public Chunk provideChunk(int x, int z) { 22 | return null; 23 | } 24 | 25 | @Override 26 | public Chunk provideChunk(BlockPos blockPosIn) { 27 | return null; 28 | } 29 | 30 | @Override 31 | public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { 32 | 33 | } 34 | 35 | @Override 36 | public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { 37 | return false; 38 | } 39 | 40 | @Override 41 | public boolean saveChunks(boolean p_73151_1_, IProgressUpdate progressCallback) { 42 | return false; 43 | } 44 | 45 | @Override 46 | public boolean unloadQueuedChunks() { 47 | return false; 48 | } 49 | 50 | @Override 51 | public boolean canSave() { 52 | return false; 53 | } 54 | 55 | @Override 56 | public String makeString() { 57 | return null; 58 | } 59 | 60 | @Override 61 | public List getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) { 62 | return null; 63 | } 64 | 65 | @Override 66 | public BlockPos getStrongholdGen(World worldIn, String structureName, BlockPos position) { 67 | return null; 68 | } 69 | 70 | @Override 71 | public int getLoadedChunkCount() { 72 | return 0; 73 | } 74 | 75 | @Override 76 | public void recreateStructures(Chunk p_180514_1_, int p_180514_2_, int p_180514_3_) { 77 | 78 | } 79 | 80 | @Override 81 | public void saveExtraData() { 82 | 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /FakeUtils/FakeNetworkManager.java: -------------------------------------------------------------------------------- 1 | 2 | import net.minecraft.network.EnumPacketDirection; 3 | import net.minecraft.network.NetworkManager; 4 | 5 | public class FakeNetworkManager extends NetworkManager { 6 | 7 | //Not sure if I need to override anything in here. It seems to work fine without overriding packets being sent 8 | 9 | public FakeNetworkManager(EnumPacketDirection packetDirection) { 10 | super(packetDirection); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /FakeUtils/FakeNetworkPlayerInfo.java: -------------------------------------------------------------------------------- 1 | import com.mojang.authlib.GameProfile; 2 | 3 | import net.minecraft.client.network.NetworkPlayerInfo; 4 | import net.minecraft.scoreboard.ScorePlayerTeam; 5 | import net.minecraft.util.ChatComponentText; 6 | import net.minecraft.util.IChatComponent; 7 | import net.minecraft.world.WorldSettings.GameType; 8 | 9 | public class FakeNetworkPlayerInfo extends NetworkPlayerInfo { 10 | 11 | public FakeNetworkPlayerInfo(GameProfile gp) { 12 | super(gp); 13 | } 14 | 15 | @Override 16 | public IChatComponent getDisplayName() { 17 | return new ChatComponentText(getGameProfile().getName()); 18 | } 19 | 20 | @Override 21 | public GameType getGameType() { 22 | return GameType.CREATIVE; 23 | } 24 | 25 | @Override 26 | public int getResponseTime() { 27 | return 0; 28 | } 29 | 30 | //slim, default 31 | @Override 32 | public String getSkinType() { 33 | return "default"; 34 | } 35 | 36 | @Override 37 | public ScorePlayerTeam getPlayerTeam() { 38 | return null; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /FakeUtils/FakePlayer.java: -------------------------------------------------------------------------------- 1 | import java.util.UUID; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.entity.EntityPlayerSP; 7 | import net.minecraft.client.network.NetHandlerPlayClient; 8 | import net.minecraft.client.network.NetworkPlayerInfo; 9 | import net.minecraft.entity.player.EnumPlayerModelParts; 10 | import net.minecraft.network.EnumPacketDirection; 11 | import net.minecraft.util.MovementInput; 12 | import net.minecraft.util.ResourceLocation; 13 | import net.minecraft.world.World; 14 | 15 | public class FakePlayer extends EntityPlayerSP { 16 | 17 | public FakePlayer(Minecraft mc, World world) { 18 | this(mc, world, checkNullGameProfile()); 19 | } 20 | 21 | public FakePlayer(Minecraft mc, World world, GameProfile gp) { 22 | super(mc, world, new NetHandlerPlayClient(mc, mc.currentScreen, new FakeNetworkManager(EnumPacketDirection.CLIENTBOUND), gp) { 23 | @Override 24 | public NetworkPlayerInfo getPlayerInfo(String p_175104_1_) { 25 | return new FakeNetworkPlayerInfo(gp); 26 | } 27 | @Override 28 | public NetworkPlayerInfo getPlayerInfo(UUID p_175102_1_) { 29 | return new FakeNetworkPlayerInfo(gp); 30 | } 31 | }, null); 32 | 33 | this.dimension = 0; 34 | this.movementInput = new MovementInput(); 35 | this.posX = 0; 36 | this.posY = 0; 37 | this.posZ = 0; 38 | } 39 | 40 | @Override 41 | public float getEyeHeight() { 42 | return 1.82F; 43 | } 44 | 45 | @Override 46 | public boolean isWearing(EnumPlayerModelParts p_175148_1_) { 47 | return true; 48 | } 49 | 50 | //getPlayerInfo() is aparently not called in hasPlayerInfo? Not super sure why 51 | @Override 52 | public boolean hasPlayerInfo() { 53 | return true; 54 | } 55 | 56 | //might not be nessessary, not sure as of now 57 | @Override 58 | protected NetworkPlayerInfo getPlayerInfo() { 59 | return new FakeNetworkPlayerInfo(getGameProfile()); 60 | } 61 | 62 | //Some people were experiencing a null GameProfile for their session 63 | //Not sure why, but his is a fix for it 64 | private static GameProfile checkNullGameProfile() { 65 | if(Minecraft.getMinecraft().getSession() == null || Minecraft.getMinecraft().getSession().getProfile() == null) { 66 | return new GameProfile(UUID.randomUUID(), "FakePlayer"); 67 | } 68 | return Minecraft.getMinecraft().getSession().getProfile(); 69 | } 70 | } -------------------------------------------------------------------------------- /FakeUtils/FakeSaveHandler.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import java.io.File; 4 | 5 | import net.minecraft.nbt.NBTTagCompound; 6 | import net.minecraft.world.MinecraftException; 7 | import net.minecraft.world.WorldProvider; 8 | import net.minecraft.world.chunk.storage.IChunkLoader; 9 | import net.minecraft.world.storage.IPlayerFileData; 10 | import net.minecraft.world.storage.ISaveHandler; 11 | import net.minecraft.world.storage.WorldInfo; 12 | 13 | public class FakeSaveHandler implements ISaveHandler { 14 | 15 | @Override 16 | public WorldInfo loadWorldInfo() { 17 | return null; 18 | } 19 | 20 | @Override 21 | public void checkSessionLock() throws MinecraftException { 22 | 23 | } 24 | 25 | @Override 26 | public IChunkLoader getChunkLoader(WorldProvider provider) { 27 | return null; 28 | } 29 | 30 | @Override 31 | public void saveWorldInfoWithPlayer(WorldInfo worldInformation, NBTTagCompound tagCompound) { 32 | 33 | } 34 | 35 | @Override 36 | public void saveWorldInfo(WorldInfo worldInformation) { 37 | 38 | } 39 | 40 | @Override 41 | public IPlayerFileData getPlayerNBTManager() { 42 | return null; 43 | } 44 | 45 | @Override 46 | public void flush() { 47 | 48 | } 49 | 50 | @Override 51 | public File getWorldDirectory() { 52 | return null; 53 | } 54 | 55 | @Override 56 | public File getMapFileFromName(String mapName) { 57 | return null; 58 | } 59 | 60 | @Override 61 | public String getWorldDirectoryName() { 62 | return ""; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /FakeUtils/FakeWorld.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import java.util.List; 4 | 5 | import com.google.common.base.Predicate; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Collection; 9 | 10 | import net.minecraft.block.Block; 11 | import net.minecraft.block.material.Material; 12 | import net.minecraft.block.state.IBlockState; 13 | import net.minecraft.entity.Entity; 14 | import net.minecraft.entity.EnumCreatureType; 15 | import net.minecraft.entity.player.EntityPlayer; 16 | import net.minecraft.init.Blocks; 17 | import net.minecraft.nbt.NBTTagCompound; 18 | import net.minecraft.profiler.Profiler; 19 | import net.minecraft.tileentity.TileEntity; 20 | import net.minecraft.util.AxisAlignedBB; 21 | import net.minecraft.util.BlockPos; 22 | import net.minecraft.util.EnumFacing; 23 | import net.minecraft.util.EnumParticleTypes; 24 | import net.minecraft.util.MovingObjectPosition; 25 | import net.minecraft.util.Vec3; 26 | import net.minecraft.world.EnumSkyBlock; 27 | import net.minecraft.world.MinecraftException; 28 | import net.minecraft.world.World; 29 | import net.minecraft.world.WorldProvider; 30 | import net.minecraft.world.WorldSavedData; 31 | import net.minecraft.world.biome.BiomeGenBase; 32 | import net.minecraft.world.biome.BiomeGenPlains; 33 | import net.minecraft.world.border.WorldBorder; 34 | import net.minecraft.world.chunk.Chunk; 35 | import net.minecraft.world.chunk.IChunkProvider; 36 | import net.minecraft.world.storage.ISaveHandler; 37 | import net.minecraft.world.storage.WorldInfo; 38 | 39 | public class FakeWorld extends World { 40 | 41 | public FakeWorld(WorldInfo info) { 42 | super(new FakeSaveHandler(), info, new FakeWorldProvider(), new Profiler(), true); 43 | this.provider.registerWorld(this); 44 | } 45 | 46 | @Override 47 | protected IChunkProvider createChunkProvider() { 48 | return new FakeChunkProvider(); 49 | } 50 | 51 | @Override 52 | protected int getRenderDistanceChunks() { 53 | return 0; 54 | } 55 | 56 | @Override 57 | public BiomeGenBase getBiomeGenForCoords(BlockPos pos) { 58 | return BiomeGenBase.plains; 59 | } 60 | 61 | @Override 62 | protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) { 63 | return false; 64 | } 65 | 66 | @Override 67 | public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) { 68 | return new BlockPos(pos.getX(), 63, pos.getZ()); 69 | } 70 | 71 | @Override 72 | public boolean isAirBlock(BlockPos pos) { 73 | return pos.getY() > 63; 74 | } 75 | 76 | @Override 77 | public IBlockState getBlockState(BlockPos pos) { 78 | return pos.getY() > 63 ? Blocks.air.getDefaultState() : Blocks.grass.getDefaultState(); 79 | } 80 | 81 | @Override 82 | public boolean setBlockState(BlockPos pos, IBlockState newState, int flags) { 83 | return true; 84 | } 85 | 86 | @Override 87 | public boolean setBlockState(BlockPos pos, IBlockState state) { 88 | return true; 89 | } 90 | 91 | @Override 92 | public boolean setBlockToAir(BlockPos pos) { 93 | return true; 94 | } 95 | 96 | @Override 97 | public void markChunkDirty(BlockPos pos, TileEntity unusedTileEntity) { 98 | 99 | } 100 | 101 | @Override 102 | public void notifyNeighborsOfStateChange(BlockPos pos, Block blockType) { 103 | 104 | } 105 | 106 | @Override 107 | public boolean destroyBlock(BlockPos pos, boolean dropBlock) { 108 | return this.isAirBlock(pos); 109 | } 110 | 111 | @Override 112 | public void notifyBlockOfStateChange(BlockPos pos, Block blockIn) { 113 | 114 | } 115 | 116 | @Override 117 | public void notifyNeighborsOfStateExcept(BlockPos pos, Block blockType, EnumFacing skipSide) { 118 | 119 | } 120 | 121 | @Override 122 | public void markBlockForUpdate(BlockPos pos) { 123 | 124 | } 125 | 126 | @Override 127 | public void notifyLightSet(BlockPos pos) { 128 | 129 | } 130 | 131 | @Override 132 | public void notifyNeighborsRespectDebug(BlockPos pos, Block blockType) { 133 | 134 | } 135 | 136 | @Override 137 | public void markBlockRangeForRenderUpdate(BlockPos rangeMin, BlockPos rangeMax) { 138 | 139 | } 140 | 141 | @Override 142 | public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) { 143 | 144 | } 145 | 146 | @Override 147 | public void markBlocksDirtyVertical(int x1, int z1, int x2, int z2) { 148 | 149 | } 150 | 151 | @Override 152 | public void markTileEntityForRemoval(TileEntity tileEntityIn) { 153 | 154 | } 155 | 156 | @Override 157 | public boolean isBlockTickPending(BlockPos pos, Block blockType) { 158 | return false; 159 | } 160 | 161 | @Override 162 | public int getLight(BlockPos pos) { 163 | return 14; 164 | } 165 | 166 | @Override 167 | public int getLight(BlockPos pos, boolean checkNeighbors) { 168 | return 14; 169 | } 170 | 171 | @Override 172 | public int getLightFor(EnumSkyBlock type, BlockPos pos) { 173 | return 14; 174 | } 175 | 176 | @Override 177 | public int getLightFromNeighbors(BlockPos pos) { 178 | return 14; 179 | } 180 | 181 | @Override 182 | public int getLightFromNeighborsFor(EnumSkyBlock type, BlockPos pos) { 183 | return 14; 184 | } 185 | 186 | @Override 187 | public boolean canBlockSeeSky(BlockPos pos) { 188 | return pos.getY() > 62; 189 | } 190 | 191 | @Override 192 | public BlockPos getHeight(BlockPos pos) { 193 | return new BlockPos(pos.getX(), 63, pos.getZ()); 194 | } 195 | 196 | @Override 197 | public int getChunksLowestHorizon(int x, int z) { 198 | return 63; 199 | } 200 | 201 | @Override 202 | protected void updateBlocks() { 203 | 204 | } 205 | 206 | @Override 207 | public void setLightFor(EnumSkyBlock type, BlockPos pos, int lightValue) { 208 | 209 | } 210 | 211 | @Override 212 | public float getLightBrightness(BlockPos pos) { 213 | return 1f; 214 | } 215 | 216 | @Override 217 | public float getSunBrightness(float p_72971_1_) { 218 | return 1f; 219 | } 220 | 221 | @Override 222 | public boolean isDaytime() { 223 | return true; 224 | } 225 | 226 | @Override 227 | public void playSound(double x, double y, double z, String soundName, float volume, float pitch, boolean distanceDelay) { 228 | 229 | } 230 | 231 | @Override 232 | public void playSoundAtEntity(Entity entityIn, String name, float volume, float pitch) { 233 | 234 | } 235 | 236 | @Override 237 | public void playSoundEffect(double x, double y, double z, String soundName, float volume, float pitch) { 238 | 239 | } 240 | 241 | @Override 242 | public void playSoundToNearExcept(EntityPlayer player, String name, float volume, float pitch) { 243 | 244 | } 245 | 246 | @Override 247 | public void spawnParticle(EnumParticleTypes particleType, boolean p_175682_2_, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int... p_175682_15_) { 248 | 249 | } 250 | 251 | @Override 252 | public void spawnParticle(EnumParticleTypes particleType, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int... p_175688_14_) { 253 | 254 | } 255 | 256 | @Override 257 | public void playRecord(BlockPos pos, String name) { 258 | 259 | } 260 | 261 | @Override 262 | public MovingObjectPosition rayTraceBlocks(Vec3 p_72933_1_, Vec3 p_72933_2_) { 263 | return null; 264 | } 265 | 266 | @Override 267 | public MovingObjectPosition rayTraceBlocks(Vec3 start, Vec3 end, boolean stopOnLiquid) { 268 | return null; 269 | } 270 | 271 | @Override 272 | public MovingObjectPosition rayTraceBlocks(Vec3 vec31, Vec3 vec32, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) { 273 | return null; 274 | } 275 | 276 | @Override 277 | public boolean addWeatherEffect(Entity entityIn) { 278 | return false; 279 | } 280 | 281 | @Override 282 | public boolean spawnEntityInWorld(Entity entityIn) { 283 | return false; 284 | } 285 | 286 | @Override 287 | protected void onEntityAdded(Entity entityIn) { 288 | 289 | } 290 | 291 | @Override 292 | protected void onEntityRemoved(Entity entityIn) { 293 | 294 | } 295 | 296 | @Override 297 | public void removeEntity(Entity entityIn) { 298 | 299 | } 300 | 301 | @Override 302 | public void removePlayerEntityDangerously(Entity entityIn) { 303 | 304 | } 305 | 306 | @Override 307 | public int calculateSkylightSubtracted(float p_72967_1_) { 308 | return 6; 309 | } 310 | 311 | @Override 312 | public void scheduleBlockUpdate(BlockPos pos, Block blockIn, int delay, int priority) { 313 | 314 | } 315 | 316 | @Override 317 | public void updateEntities() { 318 | 319 | } 320 | 321 | @Override 322 | public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate) { 323 | if (forceUpdate) { 324 | ++entityIn.ticksExisted; 325 | } 326 | } 327 | 328 | @Override 329 | public boolean checkNoEntityCollision(AxisAlignedBB bb) { 330 | return true; 331 | } 332 | 333 | @Override 334 | public boolean checkNoEntityCollision(AxisAlignedBB bb, Entity entityIn) { 335 | return true; 336 | } 337 | 338 | @Override 339 | public boolean checkBlockCollision(AxisAlignedBB bb) { 340 | return false; 341 | } 342 | 343 | @Override 344 | public boolean isAnyLiquid(AxisAlignedBB bb) { 345 | return false; 346 | } 347 | 348 | @Override 349 | public boolean handleMaterialAcceleration(AxisAlignedBB par1AxisAlignedBB, Material par2Material, Entity par3Entity) { 350 | return false; 351 | } 352 | 353 | @Override 354 | public boolean isMaterialInBB(AxisAlignedBB par1AxisAlignedBB, Material par2Material) { 355 | return false; 356 | } 357 | 358 | @Override 359 | public boolean isAABBInMaterial(AxisAlignedBB par1AxisAlignedBB, Material par2Material) { 360 | return false; 361 | } 362 | 363 | @Override 364 | public TileEntity getTileEntity(BlockPos pos) { 365 | return null; 366 | } 367 | 368 | @Override 369 | public boolean extinguishFire(EntityPlayer player, BlockPos pos, EnumFacing side) { 370 | return true; 371 | } 372 | 373 | @Override 374 | public String getDebugLoadedEntities() { 375 | return ""; 376 | } 377 | 378 | @Override 379 | public String getProviderName() { 380 | return ""; 381 | } 382 | 383 | @Override 384 | public void setTileEntity(BlockPos pos, TileEntity tileEntityIn) { 385 | 386 | } 387 | 388 | @Override 389 | public void removeTileEntity(BlockPos pos) { 390 | 391 | } 392 | 393 | @Override 394 | public boolean isBlockNormalCube(BlockPos pos, boolean _default) { 395 | return true; 396 | } 397 | 398 | @Override 399 | public void tick() { 400 | 401 | } 402 | 403 | @Override 404 | protected void updateWeather() { 405 | 406 | } 407 | 408 | @Override 409 | public boolean canBlockFreezeWater(BlockPos pos) { 410 | return false; 411 | } 412 | 413 | @Override 414 | public boolean canBlockFreezeNoWater(BlockPos pos) { 415 | return false; 416 | } 417 | 418 | @Override 419 | public boolean canBlockFreeze(BlockPos pos, boolean noWaterAdj) { 420 | return false; 421 | } 422 | 423 | @Override 424 | public boolean canSnowAt(BlockPos pos, boolean checkLight) { 425 | return false; 426 | } 427 | 428 | @Override 429 | public boolean tickUpdates(boolean par1) { 430 | return false; 431 | } 432 | 433 | @Override 434 | public List getPendingBlockUpdates(Chunk par1Chunk, boolean par2) { 435 | return null; 436 | } 437 | 438 | @Override 439 | public Entity findNearestEntityWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, Entity par3Entity) { 440 | return null; 441 | } 442 | 443 | @Override 444 | public void loadEntities(Collection entityCollection) { 445 | 446 | } 447 | 448 | @Override 449 | public void unloadEntities(Collection entityCollection) { 450 | 451 | } 452 | 453 | @Override 454 | public int countEntities(Class par1Class) { 455 | return 0; 456 | } 457 | 458 | @Override 459 | public int getStrongPower(BlockPos pos) { 460 | return 0; 461 | } 462 | 463 | @Override 464 | public int getStrongPower(BlockPos pos, EnumFacing direction) { 465 | return 0; 466 | } 467 | 468 | @Override 469 | public boolean isSidePowered(BlockPos pos, EnumFacing side) { 470 | return false; 471 | } 472 | 473 | @Override 474 | public int getRedstonePower(BlockPos pos, EnumFacing facing) { 475 | return 0; 476 | } 477 | 478 | @Override 479 | public boolean isBlockPowered(BlockPos pos) { 480 | return false; 481 | } 482 | 483 | @Override 484 | public int isBlockIndirectlyGettingPowered(BlockPos pos) { 485 | return 0; 486 | } 487 | 488 | @Override 489 | public void checkSessionLock() throws MinecraftException { 490 | } 491 | 492 | @Override 493 | public long getSeed() { 494 | return 1; 495 | } 496 | 497 | @Override 498 | public long getTotalWorldTime() { 499 | return 1; 500 | } 501 | 502 | @Override 503 | public long getWorldTime() { 504 | return 1; 505 | } 506 | 507 | @Override 508 | public void setWorldTime(long par1) { 509 | } 510 | 511 | @Override 512 | public BlockPos getSpawnPoint() { 513 | return new BlockPos(0, 64, 0); 514 | } 515 | 516 | @Override 517 | public void joinEntityInSurroundings(Entity par1Entity) { 518 | } 519 | 520 | @Override 521 | public boolean canSeeSky(BlockPos pos) { 522 | return pos.getY() > 62; 523 | } 524 | 525 | @Override 526 | public void setEntityState(Entity par1Entity, byte par2) { 527 | } 528 | 529 | @Override 530 | public float getThunderStrength(float delta) { 531 | return 0.0F; 532 | } 533 | 534 | @Override 535 | public void addBlockEvent(BlockPos pos, Block blockIn, int eventID, int eventParam) { 536 | } 537 | 538 | @Override 539 | public void updateAllPlayersSleepingFlag() { 540 | } 541 | 542 | @Override 543 | public void setThunderStrength(float p_147442_1_) { 544 | } 545 | 546 | @Override 547 | public float getRainStrength(float par1) { 548 | return 0.0F; 549 | } 550 | 551 | @Override 552 | public void setRainStrength(float par1) { 553 | } 554 | 555 | @Override 556 | public boolean isThundering() { 557 | return false; 558 | } 559 | 560 | @Override 561 | public boolean isRaining() { 562 | return false; 563 | } 564 | 565 | @Override 566 | public boolean isBlockinHighHumidity(BlockPos pos) { 567 | return false; 568 | } 569 | 570 | @Override 571 | public void setItemData(String par1Str, WorldSavedData par2WorldSavedData) { 572 | } 573 | 574 | @Override 575 | public void playBroadcastSound(int p_175669_1_, BlockPos pos, int p_175669_3_) { 576 | } 577 | 578 | @Override 579 | public void playAuxSFX(int p_175718_1_, BlockPos pos, int p_175718_3_) { 580 | 581 | } 582 | 583 | @Override 584 | public void playAuxSFXAtEntity(EntityPlayer player, int sfxType, BlockPos pos, int p_180498_4_) { 585 | 586 | } 587 | 588 | @Override 589 | public int getHeight() { 590 | return 256; 591 | } 592 | 593 | @Override 594 | public int getActualHeight() { 595 | return 256; 596 | } 597 | 598 | @Override 599 | public void makeFireworks(double par1, double par3, double par5, double par7, double par9, double par11, NBTTagCompound par13nbtTagCompound) { 600 | } 601 | 602 | @Override 603 | public boolean addTileEntity(TileEntity tile) { 604 | return true; 605 | } 606 | 607 | @Override 608 | public void addTileEntities(Collection tileEntityCollection) { 609 | } 610 | 611 | @Override 612 | public boolean isBlockFullCube(BlockPos pos) { 613 | return pos.getY() <= 63; 614 | } 615 | 616 | @Override 617 | public boolean isInsideBorder(WorldBorder worldBorderIn, Entity entityIn) { 618 | return true; 619 | } 620 | 621 | @Override 622 | public List getEntities(Class entityType, Predicate filter) { 623 | return new ArrayList(); 624 | } 625 | 626 | @Override 627 | public List getEntitiesInAABBexcluding(Entity entityIn, AxisAlignedBB boundingBox, Predicate predicate) { 628 | return new ArrayList(); 629 | } 630 | 631 | @Override 632 | public List getEntitiesWithinAABB(Class classEntity, AxisAlignedBB bb) { 633 | return new ArrayList(); 634 | } 635 | 636 | @Override 637 | public List getEntitiesWithinAABB(Class clazz, AxisAlignedBB aabb, Predicate filter) { 638 | return new ArrayList(); 639 | } 640 | 641 | @Override 642 | public List getEntitiesWithinAABBExcludingEntity(Entity entityIn, AxisAlignedBB bb) { 643 | return new ArrayList(); 644 | } 645 | 646 | @Override 647 | public IChunkProvider getChunkProvider() { 648 | return new FakeChunkProvider(); 649 | } 650 | 651 | @Override 652 | public Chunk getChunkFromChunkCoords(int par1, int par2) { 653 | return null; 654 | } 655 | 656 | } 657 | -------------------------------------------------------------------------------- /FakeUtils/FakeWorldProvider.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import net.minecraft.util.BlockPos; 4 | import net.minecraft.world.WorldProvider; 5 | import net.minecraft.world.chunk.IChunkProvider; 6 | 7 | public class FakeWorldProvider extends WorldProvider { 8 | 9 | @Override 10 | public String getDimensionName() { 11 | return ""; 12 | } 13 | 14 | @Override 15 | public String getInternalNameSuffix() { 16 | return ""; 17 | } 18 | 19 | @Override 20 | public BlockPos getSpawnCoordinate() { 21 | return new BlockPos(0, 64, 0); 22 | } 23 | 24 | @Override 25 | public IChunkProvider createChunkGenerator() { 26 | return new FakeChunkProvider(); 27 | } 28 | 29 | @Override 30 | public boolean canCoordinateBeSpawn(int x, int z) { 31 | return true; 32 | } 33 | 34 | @Override 35 | public boolean canRespawnHere() { 36 | return true; 37 | } 38 | 39 | @Override 40 | public boolean isSurfaceWorld() { 41 | return true; 42 | } 43 | 44 | @Override 45 | public int getAverageGroundLevel() { 46 | return 63; 47 | } 48 | 49 | @Override 50 | public boolean doesXZShowFog(int x, int z) { 51 | return false; 52 | } 53 | 54 | @Override 55 | public boolean isSkyColored() { 56 | return false; 57 | } 58 | 59 | @Override 60 | public boolean doesWaterVaporize() { 61 | return false; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /FakeUtils/README.md: -------------------------------------------------------------------------------- 1 | # FakeUtils 2 | Fake providers to render the world and entities in Gui's when you are not in a world. -------------------------------------------------------------------------------- /FakeUtils/_ExampleGui.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.test; 2 | 3 | import java.util.UUID; 4 | 5 | import com.mojang.authlib.GameProfile; 6 | 7 | import clientname.gui.test.fakeplayer.FakePlayer; 8 | import clientname.gui.test.fakeplayer.FakeWorld; 9 | import clientname.utils.EntityUtils; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.client.gui.GuiScreen; 12 | import net.minecraft.client.gui.ScaledResolution; 13 | import net.minecraft.client.renderer.GlStateManager; 14 | import net.minecraft.client.renderer.OpenGlHelper; 15 | import net.minecraft.client.renderer.RenderHelper; 16 | import net.minecraft.client.renderer.entity.RenderManager; 17 | import net.minecraft.entity.EntityLivingBase; 18 | import net.minecraft.entity.passive.EntityRabbit; 19 | import net.minecraft.entity.passive.EntitySheep; 20 | import net.minecraft.item.EnumDyeColor; 21 | import net.minecraft.nbt.NBTTagCompound; 22 | import net.minecraft.world.World; 23 | import net.minecraft.world.storage.WorldInfo; 24 | 25 | public class ExampleGui extends GuiScreen { 26 | 27 | private World world; 28 | private FakePlayer player; 29 | private EntitySheep sheep; 30 | private EntityRabbit rabbit; 31 | 32 | @Override 33 | public void initGui() { 34 | 35 | world = new FakeWorld(new WorldInfo(new NBTTagCompound())); 36 | 37 | player = new FakePlayer(mc, world, new GameProfile(UUID.randomUUID(), "FakePlayer")); 38 | player.setArrowCountInEntity(4); 39 | 40 | sheep = new EntitySheep(world); 41 | sheep.setFleeceColor(EnumDyeColor.YELLOW); 42 | sheep.setFire(1); 43 | 44 | rabbit = new EntityRabbit(world); 45 | rabbit.setRabbitType(3); 46 | 47 | mc.getRenderManager().cacheActiveRenderInfo(world, mc.fontRendererObj, player, player, mc.gameSettings, 0.0F); 48 | 49 | } 50 | 51 | int rotate = 0; 52 | 53 | @Override 54 | public void drawScreen(int mouseX2, int mouseY2, float partialTicks) { 55 | 56 | drawBackground(0); 57 | 58 | mc.thePlayer = player; 59 | world.updateEntity(player); 60 | 61 | 62 | 63 | if (mc.getRenderManager().worldObj == null || mc.getRenderManager().playerRenderer == null) { 64 | mc.getRenderManager().cacheActiveRenderInfo(world, mc.fontRendererObj, player, player, mc.gameSettings, 0.0F); 65 | } 66 | if ((world != null) && (player != null)) { 67 | mc.thePlayer = player; 68 | ScaledResolution sr = new ScaledResolution(mc); 69 | 70 | int distanceToSide = ((mc.currentScreen.width / 2)) / 2; 71 | float targetHeight = (float) (sr.getScaledHeight_double() / 5.0F) / 1.8F; 72 | 73 | drawEntityOnScreen( 74 | sr.getScaledWidth() - distanceToSide - 200, 75 | (int) ((sr.getScaledHeight() / 2) + (player.height * targetHeight)), 76 | targetHeight, 77 | rotate, 78 | 180, 79 | player); 80 | 81 | drawEntityOnScreen( 82 | sr.getScaledWidth() - distanceToSide - 300, 83 | (int) ((sr.getScaledHeight() / 2) + (player.height * targetHeight)), 84 | targetHeight, 85 | 0, 86 | rotate, 87 | sheep); 88 | 89 | drawEntityOnScreen( 90 | sr.getScaledWidth() - distanceToSide - 10, 91 | (int) ((sr.getScaledHeight() / 2) + (player.height * targetHeight)), 92 | rotate, 93 | rotate, 94 | 180, 95 | rabbit); 96 | 97 | 98 | rotate+=5; 99 | if(rotate<= -360 || rotate >= 360) { 100 | rotate = 0; 101 | } 102 | 103 | } 104 | 105 | super.drawScreen(mouseX2, mouseY2, partialTicks); 106 | 107 | //get rid of the player after were done rendering it. We don't want to confuse the singleplayer gods 108 | mc.thePlayer = null; 109 | } 110 | 111 | public static void drawEntityOnScreen(int posX, int posY, float scale, float yawRotate, float pitchRotate, EntityLivingBase ent) { 112 | GlStateManager.disableBlend(); 113 | GlStateManager.depthMask(true); 114 | GlStateManager.enableDepth(); 115 | GlStateManager.enableAlpha(); 116 | GlStateManager.enableColorMaterial(); 117 | GlStateManager.pushMatrix(); 118 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 119 | GlStateManager.translate(posX, posY, 50.0F); 120 | GlStateManager.scale(-scale, scale, scale); 121 | GlStateManager.rotate(pitchRotate, 0.0F, 0.0F, 1.0F); 122 | GlStateManager.rotate(yawRotate, 0.0F, 1.0F, 0.0F); 123 | float f2 = ent.renderYawOffset; 124 | float f3 = ent.rotationYaw; 125 | float f4 = ent.rotationPitch; 126 | float f5 = ent.prevRotationYawHead; 127 | float f6 = ent.rotationYawHead; 128 | RenderHelper.enableStandardItemLighting(); 129 | ent.renderYawOffset = (float) Math.atan(yawRotate / 40.0F); 130 | ent.rotationYaw = (float) Math.atan(yawRotate / 40.0F); 131 | ent.rotationPitch = -((float) Math.atan(0 / 40.0F)) * 20.0F; 132 | ent.rotationYawHead = ent.rotationYaw; 133 | ent.prevRotationYawHead = ent.rotationYaw; 134 | GlStateManager.translate(0.0F, 0.0F, 0.0F); 135 | try { 136 | RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager(); 137 | rendermanager.setPlayerViewY(180.0F); 138 | rendermanager.setRenderShadow(false); 139 | rendermanager.doRenderEntity(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, true); 140 | rendermanager.setRenderShadow(true); 141 | } 142 | finally { 143 | ent.renderYawOffset = f2; 144 | ent.rotationYaw = f3; 145 | ent.rotationPitch = f4; 146 | ent.prevRotationYawHead = f5; 147 | ent.rotationYawHead = f6; 148 | GlStateManager.popMatrix(); 149 | RenderHelper.disableStandardItemLighting(); 150 | GlStateManager.disableRescaleNormal(); 151 | GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); 152 | GlStateManager.disableTexture2D(); 153 | GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); 154 | GlStateManager.translate(0.0F, 0.0F, 20.0F); 155 | } 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /GuiChatComponents/GuiExampleChatComponent.java: -------------------------------------------------------------------------------- 1 | package clientname.gui; 2 | 3 | import java.io.IOException; 4 | 5 | import net.minecraft.client.gui.GuiButton; 6 | import net.minecraft.client.gui.GuiScreen; 7 | import net.minecraft.client.gui.GuiUtilRenderComponents; 8 | import net.minecraft.event.ClickEvent; 9 | import net.minecraft.event.HoverEvent; 10 | import net.minecraft.util.ChatComponentText; 11 | import net.minecraft.util.ChatStyle; 12 | import net.minecraft.util.EnumChatFormatting; 13 | import net.minecraft.util.IChatComponent; 14 | 15 | public class GuiExampleChatComponent extends GuiScreen { 16 | 17 | private IChatComponent[] message; 18 | private int messageLengthTimesFontHeight; 19 | 20 | private GuiButton refreshButton; 21 | 22 | public GuiExampleChatComponent() 23 | { 24 | 25 | message = new IChatComponent[] { 26 | new ChatComponentText("Hi,"), 27 | new ChatComponentText(""), 28 | 29 | new ChatComponentText("Cover over the text in [ ] to see what they do!"), 30 | new ChatComponentText(""), 31 | 32 | new ChatComponentText(EnumChatFormatting.GOLD + "Hover:"), 33 | new ChatComponentText(""), 34 | 35 | //Acts like your hovering a item 36 | new ChatComponentText(EnumChatFormatting.GOLD + "[Item]").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText("{id:stone,Count:1}")))), 37 | new ChatComponentText(""), 38 | 39 | //Shows generic text 40 | new ChatComponentText(EnumChatFormatting.GOLD + "[Text]").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Hello World, I am text")))), 41 | new ChatComponentText(""), 42 | 43 | //Shows a entity 44 | new ChatComponentText(EnumChatFormatting.GOLD + "[Entity]").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new ChatComponentText("{id:f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2,name:Herobrine}")))), 45 | new ChatComponentText(""), 46 | 47 | //Shows a achievement 48 | new ChatComponentText(EnumChatFormatting.GOLD + "[Achievement]").setChatStyle(new ChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ACHIEVEMENT, new ChatComponentText("stat.jump")))), 49 | new ChatComponentText(""), 50 | 51 | new ChatComponentText(EnumChatFormatting.BLUE + "Click:"), 52 | new ChatComponentText(""), 53 | 54 | //Opens a url to my website 55 | new ChatComponentText(EnumChatFormatting.BLUE + "[Open Url]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://eric.golde.org/"))), 56 | new ChatComponentText(""), 57 | 58 | //Opens a file, in this case, a txt document that comes with windows 59 | new ChatComponentText(EnumChatFormatting.BLUE + "[Open File]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, "C:\\Windows\\System32\\WindowsCodecsRaw.txt"))), 60 | new ChatComponentText(""), 61 | 62 | //Send a chat message into the non existant gui chat window. 63 | new ChatComponentText(EnumChatFormatting.BLUE + "[Crash]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/say hi"))), 64 | 65 | new ChatComponentText(""), 66 | //Send a chat message into the non existant gui chat window. 67 | new ChatComponentText(EnumChatFormatting.BLUE + "[Nothing]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/say hi"))), 68 | 69 | new ChatComponentText(""), 70 | //Send a chat message into the non existant gui chat window. 71 | new ChatComponentText(EnumChatFormatting.BLUE + "[Console Error 1]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.CHANGE_PAGE, "1"))), 72 | 73 | new ChatComponentText(""), 74 | //Send a chat message into the non existant gui chat window. 75 | new ChatComponentText(EnumChatFormatting.BLUE + "[Console Error 2]").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.TWITCH_USER_INFO, "loltyler1"))), 76 | }; 77 | 78 | } 79 | 80 | @Override 81 | public void initGui() 82 | { 83 | this.buttonList.clear(); 84 | 85 | this.messageLengthTimesFontHeight = this.message.length * this.fontRendererObj.FONT_HEIGHT; 86 | } 87 | 88 | @Override 89 | public void drawScreen(int mouseX, int mouseY, float partialTicks) 90 | { 91 | this.drawDefaultBackground(); 92 | 93 | int i = this.height / 2 - this.messageLengthTimesFontHeight / 2; 94 | 95 | //draw the chat components 96 | for (IChatComponent s : this.message) 97 | { 98 | this.drawCenteredString(this.fontRendererObj, s.getFormattedText(), this.width / 2, i, 16777215); 99 | i += this.fontRendererObj.FONT_HEIGHT; 100 | 101 | 102 | } 103 | 104 | handleComponentHover(findChatComponent(mouseX, mouseY), mouseX, mouseY); 105 | 106 | super.drawScreen(mouseX, mouseY, partialTicks); 107 | } 108 | 109 | 110 | private IChatComponent findChatComponentLine(int mouseY) 111 | { 112 | int i = this.height / 2 - this.messageLengthTimesFontHeight / 2; 113 | 114 | for (IChatComponent s : this.message) 115 | { 116 | int yTop = i; 117 | int yBottom = i + this.fontRendererObj.FONT_HEIGHT; 118 | if (mouseY >= yTop && mouseY < yBottom) { 119 | return s; 120 | } 121 | i += this.fontRendererObj.FONT_HEIGHT; 122 | } 123 | 124 | return null; 125 | } 126 | 127 | private IChatComponent findChatComponent(int mouseX, int mouseY) { 128 | 129 | IChatComponent s = findChatComponentLine(mouseY); 130 | 131 | if (s == null || !(s instanceof ChatComponentText)) { 132 | return null; 133 | } 134 | 135 | int stringWidth = this.mc.fontRendererObj.getStringWidth(GuiUtilRenderComponents.func_178909_a(((ChatComponentText)s).getChatComponentText_TextValue(), false)); 136 | int xLeft = this.width / 2 - stringWidth / 2; 137 | int xRight = this.width / 2 + stringWidth / 2; 138 | if (mouseX >= xLeft && mouseX < xRight) { 139 | return s; 140 | } 141 | 142 | return null; 143 | } 144 | 145 | @Override 146 | protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { 147 | if (mouseButton == 0) 148 | { 149 | IChatComponent ichatcomponent = findChatComponent(mouseX, mouseY); 150 | 151 | if (this.handleComponentClick(ichatcomponent)) 152 | { 153 | return; 154 | } 155 | } 156 | super.mouseClicked(mouseX, mouseY, mouseButton); 157 | } 158 | 159 | } -------------------------------------------------------------------------------- /GuiChatComponents/README.md: -------------------------------------------------------------------------------- 1 | # GuiChatComponents 2 | Example on how to make clickable and hoverable chat components in a gui. Feel free to adapt this to your own gui. -------------------------------------------------------------------------------- /GuiCheckBox/GuiCheckBox.java: -------------------------------------------------------------------------------- 1 | import java.awt.Color; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.FontRenderer; 5 | import net.minecraft.client.gui.GuiButton; 6 | import net.minecraft.client.renderer.GlStateManager; 7 | 8 | public class GuiCheckBox extends GuiButton { 9 | 10 | private boolean checked; 11 | 12 | //Style the button how you wish 13 | private static final String X = "✗"; 14 | private static final String CHECK = "✔"; 15 | private static final Color X_COLOR = Color.RED; 16 | private static final Color CHECK_COLOR = Color.GREEN; 17 | 18 | public GuiCheckBox(int buttonId, int x, int y) { 19 | this(buttonId, x, y, false); 20 | } 21 | 22 | public GuiCheckBox(int buttonId, int x, int y, boolean checked) { 23 | super(buttonId, x, y, 20, 20, ""); 24 | this.checked = checked; 25 | } 26 | 27 | @Override 28 | public void drawButton(Minecraft mc, int mouseX, int mouseY) { 29 | if (this.visible) { 30 | FontRenderer fontrenderer = mc.fontRendererObj; 31 | mc.getTextureManager().bindTexture(buttonTextures); 32 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 33 | this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; 34 | int i = this.getHoverState(this.hovered); 35 | GlStateManager.enableBlend(); 36 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); 37 | GlStateManager.blendFunc(770, 771); 38 | this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height); 39 | this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); 40 | this.mouseDragged(mc, mouseX, mouseY); 41 | 42 | this.displayString = X; 43 | int color = X_COLOR.getRGB(); 44 | 45 | if(checked) { 46 | this.displayString = CHECK; 47 | color = CHECK_COLOR.getRGB(); 48 | } 49 | 50 | this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, color); 51 | 52 | } 53 | } 54 | 55 | @Override 56 | public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { 57 | 58 | if(super.mousePressed(mc, mouseX, mouseY)) { 59 | checked = !checked; 60 | return true; 61 | } 62 | 63 | return false; 64 | } 65 | 66 | public boolean isChecked() { 67 | return checked; 68 | } 69 | 70 | public void setChecked(boolean checked) { 71 | this.checked = checked; 72 | } 73 | 74 | 75 | 76 | } 77 | -------------------------------------------------------------------------------- /GuiCheckBox/README.md: -------------------------------------------------------------------------------- 1 | # GuiCheckbox 2 | Simple Minecraft Styled toggle button. 3 | 4 | ## How to use 5 | Add it just like you would a normal GuiButton. You can use .isChecked() and .setChecked(). By default, it is not checked. 6 | -------------------------------------------------------------------------------- /GuiScrollExample/GuiTestList.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.tst.scroll; 2 | 3 | import java.io.IOException; 4 | 5 | import net.minecraft.client.gui.GuiButton; 6 | import net.minecraft.client.gui.GuiOptionButton; 7 | import net.minecraft.client.gui.GuiOptionSlider; 8 | import net.minecraft.client.gui.GuiScreen; 9 | import net.minecraft.client.settings.GameSettings; 10 | import net.minecraft.client.settings.KeyBinding; 11 | 12 | public class GuiTestList extends GuiScreen { 13 | 14 | private ScrollListTest scrollerThingy; 15 | 16 | @Override 17 | public void initGui() { 18 | 19 | scrollerThingy = new ScrollListTest(mc, this); 20 | this.buttonList.clear(); 21 | 22 | } 23 | 24 | @Override 25 | public void handleMouseInput() throws IOException 26 | { 27 | super.handleMouseInput(); 28 | this.scrollerThingy.handleMouseInput(); 29 | } 30 | 31 | @Override 32 | protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { 33 | if (mouseButton != 0 || !this.scrollerThingy.mouseClicked(mouseX, mouseY, mouseButton)) 34 | { 35 | super.mouseClicked(mouseX, mouseY, mouseButton); 36 | } 37 | } 38 | 39 | @Override 40 | protected void mouseReleased(int mouseX, int mouseY, int state) 41 | { 42 | if (state != 0 || !this.scrollerThingy.mouseReleased(mouseX, mouseY, state)) 43 | { 44 | super.mouseReleased(mouseX, mouseY, state); 45 | } 46 | } 47 | 48 | @Override 49 | public void drawScreen(int mouseX, int mouseY, float partialTicks) 50 | { 51 | //this.drawDefaultBackground(); 52 | this.scrollerThingy.drawScreen(mouseX, mouseY, partialTicks); 53 | this.drawCenteredString(this.fontRendererObj, "Scroll Test (Like controls)", this.width / 2, 8, 16777215); 54 | 55 | super.drawScreen(mouseX, mouseY, partialTicks); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /GuiScrollExample/README.md: -------------------------------------------------------------------------------- 1 | # GuiScrollExample 2 | Example on how to make a scrolling gui. Code pretty much taken from GuiControls entirely. -------------------------------------------------------------------------------- /GuiScrollExample/ScrollListTest.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.tst.scroll; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.GuiButton; 8 | import net.minecraft.client.gui.GuiListExtended; 9 | 10 | public class ScrollListTest extends GuiListExtended { 11 | 12 | private final List entrys = new ArrayList(); 13 | 14 | public ScrollListTest(Minecraft mcIn, GuiTestList inGui) { 15 | super(mcIn, inGui.width, inGui.height, 63, inGui.height - 32, 20); 16 | for(int i = 0; i < 100; i++) { 17 | entrys.add(new BtnEntry("Btn: " + i)); 18 | } 19 | } 20 | 21 | @Override 22 | public IGuiListEntry getListEntry(int index) { 23 | return entrys.get(index); 24 | } 25 | 26 | @Override 27 | protected int getSize() { 28 | return entrys.size(); 29 | } 30 | 31 | public class BtnEntry implements GuiListExtended.IGuiListEntry 32 | { 33 | private final GuiButton btn; 34 | private final GuiButton btn2; 35 | 36 | private BtnEntry(String name) 37 | { 38 | this.btn = new GuiButton(0, 0, 0, 75, 20, name); 39 | this.btn2 = new GuiButton(0, 0, 0, 75, 20, name + " - 2"); 40 | } 41 | 42 | @Override 43 | public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) 44 | { 45 | this.btn.xPosition = x; 46 | this.btn.yPosition = y; 47 | this.btn.drawButton(ScrollListTest.this.mc, mouseX, mouseY); 48 | 49 | this.btn2.xPosition = x + 100; 50 | this.btn2.yPosition = y; 51 | this.btn2.drawButton(ScrollListTest.this.mc, mouseX, mouseY); 52 | } 53 | 54 | @Override 55 | public boolean mousePressed(int slotIndex, int x, int y, int p_148278_4_, int p_148278_5_, int p_148278_6_) 56 | { 57 | return this.btn.mousePressed(mc, x, y); 58 | } 59 | 60 | @Override 61 | public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) 62 | { 63 | this.btn.mouseReleased(x, y); 64 | } 65 | 66 | @Override 67 | public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_) 68 | { 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /JarLoader/GenericJarLoader/res/plugins/ExamplePlugin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/GenericJarLoader/res/plugins/ExamplePlugin.jar -------------------------------------------------------------------------------- /JarLoader/GenericJarLoader/src/org/golde/genericjarloader/Main.java: -------------------------------------------------------------------------------- 1 | package org.golde.genericjarloader; 2 | 3 | import java.io.File; 4 | 5 | public class Main { 6 | 7 | 8 | /* 9 | * Test Code: 10 | * 11 | * Load all plugins in the res/plugins folder 12 | * 13 | * Wait 3 seconds 14 | * 15 | * Unload all plugins in the res/plugins folder 16 | * 17 | * Exit Program 18 | */ 19 | 20 | public static void main(String[] args) throws InterruptedException { 21 | 22 | //create a new plugin loader 23 | PluginLoader loader = new PluginLoader(); 24 | 25 | //Plugins folder 26 | File pluginsFolder = new File("res/plugins"); 27 | 28 | //Loop over every jar file and load it 29 | //TODO: If it doesn't end in .jar its not a plugin 30 | for(File f : pluginsFolder.listFiles()) { 31 | 32 | loader.load(f); 33 | 34 | } 35 | 36 | //Sleep for 3 seconds 37 | Thread.sleep(3000); 38 | 39 | 40 | //Loop over every jar file and unload it 41 | //TODO: If it doesn't end in .jar its not a plugin 42 | for(File f : pluginsFolder.listFiles()) { 43 | 44 | loader.unload(f); 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /JarLoader/GenericJarLoader/src/org/golde/genericjarloader/PluginLoader.java: -------------------------------------------------------------------------------- 1 | package org.golde.genericjarloader; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.lang.reflect.Constructor; 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.net.MalformedURLException; 10 | import java.net.URL; 11 | import java.net.URLClassLoader; 12 | import java.util.Enumeration; 13 | import java.util.HashMap; 14 | import java.util.zip.ZipEntry; 15 | import java.util.zip.ZipFile; 16 | 17 | import org.golde.genericjarloader.api.Plugin; 18 | import org.golde.genericjarloader.api.PluginDescriptionFile; 19 | import org.golde.genericjarloader.api.PluginException; 20 | 21 | import com.google.gson.Gson; 22 | import com.google.gson.GsonBuilder; 23 | import com.google.gson.JsonParseException; 24 | 25 | public class PluginLoader { 26 | 27 | //JSON instance for the plugin.json file 28 | private static final Gson GSON = new GsonBuilder().serializeNulls().create(); 29 | 30 | //Map from FIle to Plugin instance. 31 | //Really not the best way to do it but it works for this example 32 | private HashMap map = new HashMap(); 33 | 34 | /** 35 | * Try to load a plugin 36 | * @param file path to jar file 37 | * @return 38 | */ 39 | public Plugin load(File file) { 40 | 41 | try { 42 | 43 | //Make sure the plugin isn't loaded 44 | //if it is, throw an exception 45 | if(map.containsKey(file)) { 46 | throw new PluginException("Plugin already loaded."); 47 | } 48 | 49 | //Gets the plugin.json file out of the jar file 50 | PluginDescriptionFile pluginDescriptionFile = getPluginDescriptionFile(file); 51 | 52 | //get the class loader 53 | ClassLoader loader = URLClassLoader.newInstance( new URL[] { file.toURI().toURL() }, getClass().getClassLoader() ); 54 | 55 | //load the main class specified in the plugin.json file 56 | Class clazz = Class.forName(pluginDescriptionFile.getMain(), true, loader); 57 | 58 | //Get an instance of the main class that should be ran 59 | Class instanceClass = clazz.asSubclass(Plugin.class); 60 | 61 | //Get the constructor of the instance class 62 | Constructor instanceClassConstructor = (Constructor) instanceClass.getConstructor(); 63 | 64 | //Create a new instance of it 65 | Plugin plugin = instanceClassConstructor.newInstance(); 66 | 67 | //set the description file, so we can read it from the plugin instance. 68 | plugin.setDescriptionFile(pluginDescriptionFile); 69 | 70 | //add the plugin to the map of enabled plugins 71 | map.put(file, plugin); 72 | 73 | //let us know it loaded 74 | System.out.println("Loaded '" + plugin.getDescriptionFile().getName() + " v" + plugin.getDescriptionFile().getVersion() + "'"); 75 | 76 | //call onEnable 77 | plugin.onEnable(); 78 | 79 | //return the instance 80 | return plugin; 81 | } 82 | catch(MalformedURLException e) { 83 | throw new PluginException("Failed to convert the file path to a URL.", e); 84 | } 85 | catch(ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { 86 | throw new PluginException("Failed to create a new instance of the plugin.", e); 87 | } 88 | } 89 | 90 | /** 91 | * Unload a plugin 92 | * @param file 93 | */ 94 | public void unload(File file) { 95 | 96 | //Make sure we can't unload the plugin twice 97 | if(!map.containsKey(file)) { 98 | throw new PluginException("Can't unload a Plugin that wasn't loaded in the first place."); 99 | } 100 | 101 | //get the instance 102 | Plugin plugin = map.get(file); 103 | 104 | //call on disable 105 | plugin.onDisable(); 106 | 107 | //remove the file from the map so it can be enabled again 108 | map.remove(file); 109 | 110 | //Let us know it was unloaded 111 | System.out.println("Unloaded '" + plugin.getDescriptionFile().getName() + " v" + plugin.getDescriptionFile().getVersion() + "'"); 112 | 113 | //TODO: Garbage collect? 114 | } 115 | 116 | 117 | /** 118 | * Reload a plugin 119 | * @param file 120 | */ 121 | public void reload(File file) { 122 | unload(file); 123 | load(file); 124 | } 125 | 126 | /** 127 | * Get a plugins description file from the jar 128 | * @param file the jar file 129 | * @return a object with everything in the plugin description 130 | */ 131 | private PluginDescriptionFile getPluginDescriptionFile(File file) { 132 | 133 | try { 134 | 135 | //Create a zip file 136 | ZipFile zipFile = new ZipFile(file); 137 | 138 | //Be able to loop over every file 139 | //TODO: Only really need the top level tbh 140 | Enumeration entries = zipFile.entries(); 141 | 142 | //Break the loop when this isn't null 143 | PluginDescriptionFile pluginJson = null; 144 | 145 | //Go over every file in the zip file until we find the plugin.json file 146 | //TODO: Really only need the top level entries tbh 147 | while(entries.hasMoreElements() && pluginJson == null){ 148 | ZipEntry entry = entries.nextElement(); 149 | 150 | if(!entry.isDirectory() && entry.getName().equals("plugin.json")) { 151 | InputStream stream = zipFile.getInputStream(entry); 152 | try { 153 | //try to initalize it to a object 154 | pluginJson = GSON.fromJson(new InputStreamReader(stream), PluginDescriptionFile.class); 155 | } 156 | catch(JsonParseException jsonParseException) { 157 | throw new PluginException("Failed to parse JSON:", jsonParseException); 158 | } 159 | } 160 | } 161 | 162 | //if we don't find it, throw an excepiton 163 | if(pluginJson == null) { 164 | zipFile.close(); 165 | throw new PluginException("Failed to find plugin.json in the root of the jar."); 166 | } 167 | 168 | //close the zip 169 | zipFile.close(); 170 | 171 | //return the object 172 | return pluginJson; 173 | } 174 | catch(IOException e) { 175 | throw new PluginException("Failed to open the jar as a zip:", e); 176 | } 177 | 178 | 179 | } 180 | 181 | } 182 | -------------------------------------------------------------------------------- /JarLoader/GenericJarLoader/src/org/golde/genericjarloader/api/Plugin.java: -------------------------------------------------------------------------------- 1 | package org.golde.genericjarloader.api; 2 | 3 | public abstract class Plugin { 4 | 5 | private PluginDescriptionFile descriptionFile; 6 | 7 | public void onEnable() {}; 8 | public void onDisable() {} 9 | 10 | 11 | public final void setDescriptionFile(PluginDescriptionFile descriptionFile) { 12 | if(this.descriptionFile != null) { 13 | throw new PluginException("Can't set the description file. Its already set!"); 14 | } 15 | this.descriptionFile = descriptionFile; 16 | } 17 | 18 | //Can't use lombok to create a final getter smh 19 | public final PluginDescriptionFile getDescriptionFile() { 20 | return descriptionFile; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JarLoader/GenericJarLoader/src/org/golde/genericjarloader/api/PluginDescriptionFile.java: -------------------------------------------------------------------------------- 1 | package org.golde.genericjarloader.api; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | @AllArgsConstructor 7 | @Getter 8 | /** 9 | * An object to hold what is in the plugin.json file 10 | * Could also just use a hashmap 11 | * @author Eric Golde 12 | * 13 | */ 14 | public class PluginDescriptionFile { 15 | 16 | private final String main; 17 | private final String name; 18 | private final String version; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /JarLoader/GenericJarLoader/src/org/golde/genericjarloader/api/PluginException.java: -------------------------------------------------------------------------------- 1 | package org.golde.genericjarloader.api; 2 | 3 | /** 4 | * Generic exception for when shit hits the fan loading and unloading plugins 5 | * @author Eric Golde 6 | * 7 | */ 8 | public class PluginException extends RuntimeException { 9 | 10 | private static final long serialVersionUID = -8161437637562938254L; 11 | 12 | public PluginException(String whatHappened) { 13 | super(whatHappened); 14 | } 15 | 16 | public PluginException(String whatHappened, Throwable cause) { 17 | super(whatHappened, cause); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /JarLoader/GenericJarLoaderExamplePlugin/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.golde.genericjarloader.example.ExamplePlugin", 3 | "name": "Example Plugin", 4 | "version": "1.0.0" 5 | } -------------------------------------------------------------------------------- /JarLoader/GenericJarLoaderExamplePlugin/src/org/golde/genericjarloader/example/ExamplePlugin.java: -------------------------------------------------------------------------------- 1 | package org.golde.genericjarloader.example; 2 | 3 | import org.golde.genericjarloader.api.Plugin; 4 | 5 | /** 6 | * Exampleplugin that prints when it was enabled and disabled. 7 | * @author Eric Golde 8 | * 9 | */ 10 | public class ExamplePlugin extends Plugin { 11 | 12 | @Override 13 | public void onEnable() { 14 | System.out.println("[ExamplePlugin] I was enabled!"); 15 | } 16 | 17 | @Override 18 | public void onDisable() { 19 | System.out.println("[ExamplePlugin] I was disabled!"); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /JarLoader/README.md: -------------------------------------------------------------------------------- 1 | # Jar Loader 2 | Very crude example of loading jars into memory and calling onEnable and onDisable like spigot / forge. 3 | 4 | This is going to need some modifications to work with mods and a client, but it should be a good starting point. 5 | 6 | ## Folders 7 | GenericJarLoader - The actual API and the class that loads the jar 8 | 9 | GenericJarLoaderExample - Example plugin that prints hello world. 10 | 11 | lib - libraries for both projects. You **dont need to** use these, I used them for making my life easier. If you were to include this in a client, you could get rid of lombok, and replace GSON with org.json which is included with Minecraft by default. -------------------------------------------------------------------------------- /JarLoader/lib/gson/gson-2.8.6-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/lib/gson/gson-2.8.6-javadoc.jar -------------------------------------------------------------------------------- /JarLoader/lib/gson/gson-2.8.6-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/lib/gson/gson-2.8.6-sources.jar -------------------------------------------------------------------------------- /JarLoader/lib/gson/gson-2.8.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/lib/gson/gson-2.8.6.jar -------------------------------------------------------------------------------- /JarLoader/lib/lombok/lombok-1.18.20-javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/lib/lombok/lombok-1.18.20-javadoc.jar -------------------------------------------------------------------------------- /JarLoader/lib/lombok/lombok-1.18.20-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/lib/lombok/lombok-1.18.20-sources.jar -------------------------------------------------------------------------------- /JarLoader/lib/lombok/lombok-1.18.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/JarLoader/lib/lombok/lombok-1.18.20.jar -------------------------------------------------------------------------------- /NBTColorizer/NBTColorizer.java: -------------------------------------------------------------------------------- 1 | package your.package.goes.here; 2 | 3 | import java.util.Collection; 4 | import java.util.Collections; 5 | import java.util.HashMap; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.regex.Pattern; 10 | 11 | import com.google.common.base.Strings; 12 | import com.google.common.collect.Lists; 13 | 14 | import net.minecraft.nbt.NBTBase; 15 | import net.minecraft.nbt.NBTTagByte; 16 | import net.minecraft.nbt.NBTTagByteArray; 17 | import net.minecraft.nbt.NBTTagCompound; 18 | import net.minecraft.nbt.NBTTagDouble; 19 | import net.minecraft.nbt.NBTTagEnd; 20 | import net.minecraft.nbt.NBTTagFloat; 21 | import net.minecraft.nbt.NBTTagInt; 22 | import net.minecraft.nbt.NBTTagIntArray; 23 | import net.minecraft.nbt.NBTTagList; 24 | import net.minecraft.nbt.NBTTagLong; 25 | import net.minecraft.nbt.NBTTagLongArray; 26 | import net.minecraft.nbt.NBTTagShort; 27 | import net.minecraft.nbt.NBTTagString; 28 | import net.minecraft.util.text.ITextComponent; 29 | import net.minecraft.util.text.TextComponentString; 30 | import net.minecraft.util.text.TextFormatting; 31 | 32 | /* 33 | Note: If your using MCP, you don't need ObfuscationReflectionHelper. 34 | Make a getter for the variable that is passed in as a string. For example 35 | IN: ObfuscationReflectionHelper.getPrivateValue(NBTTagCompound.class, tag, "tagMap"); 36 | OUT: Object o = tag.getTagMap(); 37 | 38 | This was ported from 1.16 to 1.12. It may have some issues still. 39 | */ 40 | public class NBTColorizer { 41 | 42 | static TextFormatting SYNTAX_HIGHLIGHTING_KEY = TextFormatting.AQUA; 43 | static TextFormatting SYNTAX_HIGHLIGHTING_STRING = TextFormatting.GREEN; 44 | static TextFormatting SYNTAX_HIGHLIGHTING_NUMBER = TextFormatting.GOLD; 45 | static TextFormatting SYNTAX_HIGHLIGHTING_NUMBER_TYPE = TextFormatting.RED; 46 | 47 | private static final Pattern SIMPLE_VALUE = Pattern.compile("[A-Za-z0-9._+-]+"); 48 | 49 | private static ITextComponent getNameComponent(String name) { 50 | if (SIMPLE_VALUE.matcher(name).matches()) { 51 | // return (new TextComponentString(name)).mergeStyle(SYNTAX_HIGHLIGHTING_KEY); 52 | return mergeStyle(new TextComponentString(name), SYNTAX_HIGHLIGHTING_KEY); 53 | } 54 | else { 55 | String s = quoteAndEscape(name); 56 | String s1 = s.substring(0, 1); 57 | //ITextComponent itextcomponent = (new TextComponentString(s.substring(1, s.length() - 1))).mergeStyle(SYNTAX_HIGHLIGHTING_KEY); 58 | ITextComponent itextcomponent = mergeStyle((new TextComponentString(s.substring(1, s.length() - 1))), SYNTAX_HIGHLIGHTING_KEY); 59 | return (new TextComponentString(s1)).appendSibling(itextcomponent).appendText(s1); 60 | } 61 | } 62 | 63 | private static TextComponentString mergeStyle(TextComponentString in, TextFormatting tf) { 64 | in.getStyle().setColor(tf); 65 | return in; 66 | } 67 | 68 | private static String quoteAndEscape(String name) { 69 | StringBuilder stringbuilder = new StringBuilder(" "); 70 | char c0 = 0; 71 | 72 | for(int i = 0; i < name.length(); ++i) { 73 | char c1 = name.charAt(i); 74 | if (c1 == '\\') { 75 | stringbuilder.append('\\'); 76 | } else if (c1 == '"' || c1 == '\'') { 77 | if (c0 == 0) { 78 | c0 = (char)(c1 == '"' ? 39 : 34); 79 | } 80 | 81 | if (c0 == c1) { 82 | stringbuilder.append('\\'); 83 | } 84 | } 85 | 86 | stringbuilder.append(c1); 87 | } 88 | 89 | if (c0 == 0) { 90 | c0 = '"'; 91 | } 92 | 93 | stringbuilder.setCharAt(0, c0); 94 | stringbuilder.append(c0); 95 | return stringbuilder.toString(); 96 | } 97 | 98 | private static Map getTagMap(NBTTagCompound tag) { 99 | Object o = ObfuscationReflectionHelper.getPrivateValue(NBTTagCompound.class, tag, "tagMap"); 100 | 101 | if(o instanceof HashMap) { 102 | return (Map)o; 103 | } 104 | 105 | return null; 106 | 107 | } 108 | 109 | public static ITextComponent toFormattedComponent(NBTBase base) { 110 | return toFormattedComponent(base, "", 0); 111 | } 112 | 113 | public static ITextComponent toFormattedComponent(NBTBase base, String indentation, int indentDepth) { 114 | 115 | if(base instanceof NBTTagCompound) { 116 | return toFormattedComponentCompound((NBTTagCompound) base, indentation, indentDepth); 117 | } 118 | else if(base instanceof NBTTagString) { 119 | return toFormattedComponentString((NBTTagString) base, indentation, indentDepth); 120 | } 121 | else if(base instanceof NBTTagInt) { 122 | return toFormattedComponentInteger((NBTTagInt) base, indentation, indentDepth); 123 | } 124 | else if(base instanceof NBTTagFloat) { 125 | return toFormattedComponentFloat((NBTTagFloat) base, indentation, indentDepth); 126 | } 127 | else if(base instanceof NBTTagShort) { 128 | return toFormattedComponentShort((NBTTagShort) base, indentation, indentDepth); 129 | } 130 | else if(base instanceof NBTTagLong) { 131 | return toFormattedComponentLong((NBTTagLong) base, indentation, indentDepth); 132 | } 133 | else if(base instanceof NBTTagByte) { 134 | return toFormattedComponentByte((NBTTagByte) base, indentation, indentDepth); 135 | } 136 | else if(base instanceof NBTTagDouble) { 137 | return toFormattedComponentDouble((NBTTagDouble) base, indentation, indentDepth); 138 | } 139 | else if(base instanceof NBTTagByteArray) { 140 | return toFormattedComponentByteArray((NBTTagByteArray) base, indentation, indentDepth); 141 | } 142 | else if(base instanceof NBTTagLongArray) { 143 | return toFormattedComponentLongArray((NBTTagLongArray) base, indentation, indentDepth); 144 | } 145 | else if(base instanceof NBTTagIntArray) { 146 | return toFormattedComponentIntArray((NBTTagIntArray) base, indentation, indentDepth); 147 | } 148 | else if(base instanceof NBTTagList) { 149 | return toFormattedComponentTagList((NBTTagList) base, indentation, indentDepth); 150 | } 151 | else if(base instanceof NBTTagEnd) { 152 | return new TextComponentString(""); 153 | } 154 | 155 | return new TextComponentString("***ERROR:"+ base.getClass().getSimpleName() + "***"); 156 | } 157 | 158 | private static ITextComponent toFormattedComponentTagList(NBTTagList tag, String indentation, int indentDepth) { 159 | if (tag.hasNoTags()) { 160 | return new TextComponentString("[]"); 161 | } 162 | //I believe this is lists of lists, not a thing in 1.12.2 163 | // else if (typeSet.contains(this.tagType) && this.size() <= 8) { 164 | // String s1 = ", "; 165 | // ITextComponent iformattabletextcomponent2 = new TextComponentString("["); 166 | // 167 | // for(int j = 0; j < this.tagList.size(); ++j) { 168 | // if (j != 0) { 169 | // iformattabletextcomponent2.appendText(", "); 170 | // } 171 | // 172 | // iformattabletextcomponent2.appendSibling(this.tagList.get(j).toFormattedComponent()); 173 | // } 174 | // 175 | // iformattabletextcomponent2.appendText("]"); 176 | // return iformattabletextcomponent2; 177 | // } 178 | else { 179 | ITextComponent iformattabletextcomponent = new TextComponentString("["); 180 | if (!indentation.isEmpty()) { 181 | iformattabletextcomponent.appendText("\n"); 182 | } 183 | 184 | String s = String.valueOf(','); 185 | 186 | for(int i = 0; i < tag.tagCount(); ++i) { 187 | ITextComponent iformattabletextcomponent1 = new TextComponentString(Strings.repeat(indentation, indentDepth + 1)); 188 | 189 | ITextComponent formatted = toFormattedComponent(tag.get(i), indentation, indentDepth + 1); 190 | 191 | //iformattabletextcomponent1.appendSibling(this.tagList.get(i).toFormattedComponent(indentation, indentDepth + 1)); 192 | iformattabletextcomponent1.appendSibling(formatted); 193 | if (i != tag.tagCount() - 1) { 194 | iformattabletextcomponent1.appendText(s).appendText(indentation.isEmpty() ? " " : "\n"); 195 | } 196 | 197 | iformattabletextcomponent.appendSibling(iformattabletextcomponent1); 198 | } 199 | 200 | if (!indentation.isEmpty()) { 201 | iformattabletextcomponent.appendText("\n").appendText(Strings.repeat(indentation, indentDepth)); 202 | } 203 | 204 | iformattabletextcomponent.appendText("]"); 205 | return iformattabletextcomponent; 206 | } 207 | } 208 | 209 | private static ITextComponent toFormattedComponentIntArray(NBTTagIntArray tag, String indentation, int indentDepth) { 210 | // ITextComponent itextcomponent = (new TextComponentString("B")).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 211 | ITextComponent itextcomponent = mergeStyle(new TextComponentString("I"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 212 | ITextComponent iformattabletextcomponent = (new TextComponentString("[")).appendSibling(itextcomponent).appendText(";"); 213 | 214 | int[] arr = tag.getIntArray(); 215 | 216 | for(int i = 0; i < arr.length; ++i) { 217 | //ITextComponent iformattabletextcomponent1 = (new TextComponentString(String.valueOf((int)arr[i]))).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 218 | ITextComponent iformattabletextcomponent1 = mergeStyle(new TextComponentString(String.valueOf(arr[i])), SYNTAX_HIGHLIGHTING_NUMBER); 219 | iformattabletextcomponent.appendText(" ").appendSibling(iformattabletextcomponent1).appendSibling(itextcomponent); 220 | if (i != arr.length - 1) { 221 | iformattabletextcomponent.appendText(","); 222 | } 223 | } 224 | 225 | iformattabletextcomponent.appendText("]"); 226 | return iformattabletextcomponent; 227 | } 228 | 229 | private static ITextComponent toFormattedComponentLongArray(NBTTagLongArray tag, String indentation, int indentDepth) { 230 | // ITextComponent itextcomponent = (new TextComponentString("B")).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 231 | ITextComponent itextcomponent = mergeStyle(new TextComponentString("L"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 232 | ITextComponent iformattabletextcomponent = (new TextComponentString("[")).appendSibling(itextcomponent).appendText(";"); 233 | 234 | //legit there is no function. Reflection time! 235 | long[] arr = (long[]) ObfuscationReflectionHelper.getPrivateValue(NBTTagLongArray.class, tag, "data"); 236 | // long[] arr = tag.getLongArray(); 237 | 238 | for(int i = 0; i < arr.length; ++i) { 239 | //ITextComponent iformattabletextcomponent1 = (new TextComponentString(String.valueOf((int)arr[i]))).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 240 | ITextComponent iformattabletextcomponent1 = mergeStyle(new TextComponentString(String.valueOf(arr[i])), SYNTAX_HIGHLIGHTING_NUMBER); 241 | iformattabletextcomponent.appendText(" ").appendSibling(iformattabletextcomponent1).appendSibling(itextcomponent); 242 | if (i != arr.length - 1) { 243 | iformattabletextcomponent.appendText(","); 244 | } 245 | } 246 | 247 | iformattabletextcomponent.appendText("]"); 248 | return iformattabletextcomponent; 249 | } 250 | 251 | private static ITextComponent toFormattedComponentByteArray(NBTTagByteArray tag, String indentation, int indentDepth) { 252 | // ITextComponent itextcomponent = (new TextComponentString("B")).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 253 | ITextComponent itextcomponent = mergeStyle(new TextComponentString("B"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 254 | ITextComponent iformattabletextcomponent = (new TextComponentString("[")).appendSibling(itextcomponent).appendText(";"); 255 | 256 | byte[] arr = tag.getByteArray(); 257 | 258 | for(int i = 0; i < arr.length; ++i) { 259 | //ITextComponent iformattabletextcomponent1 = (new TextComponentString(String.valueOf((int)arr[i]))).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 260 | ITextComponent iformattabletextcomponent1 = mergeStyle(new TextComponentString(String.valueOf((int)arr[i])), SYNTAX_HIGHLIGHTING_NUMBER); 261 | iformattabletextcomponent.appendText(" ").appendSibling(iformattabletextcomponent1).appendSibling(itextcomponent); 262 | if (i != arr.length - 1) { 263 | iformattabletextcomponent.appendText(","); 264 | } 265 | } 266 | 267 | iformattabletextcomponent.appendText("]"); 268 | return iformattabletextcomponent; 269 | } 270 | 271 | private static ITextComponent toFormattedComponentDouble(NBTTagDouble tag, String indentation, int indentDepth) { 272 | //return (new StringTextComponent(String.valueOf(this.data))).appendSibling(itextcomponent).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 273 | ITextComponent t1 = mergeStyle(new TextComponentString("d"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 274 | return mergeStyle(new TextComponentString(String.valueOf(tag.getDouble())), SYNTAX_HIGHLIGHTING_NUMBER).appendSibling(t1); 275 | } 276 | 277 | private static ITextComponent toFormattedComponentByte(NBTTagByte tag, String indentation, int indentDepth) { 278 | //return (new StringTextComponent(String.valueOf(this.data))).appendSibling(itextcomponent).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 279 | ITextComponent t1 = mergeStyle(new TextComponentString("b"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 280 | return mergeStyle(new TextComponentString(String.valueOf(tag.getByte())), SYNTAX_HIGHLIGHTING_NUMBER).appendSibling(t1); 281 | } 282 | 283 | private static ITextComponent toFormattedComponentLong(NBTTagLong tag, String indentation, int indentDepth) { 284 | //return (new StringTextComponent(String.valueOf(this.data))).appendSibling(itextcomponent).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 285 | ITextComponent t1 = mergeStyle(new TextComponentString("L"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 286 | return mergeStyle(new TextComponentString(String.valueOf(tag.getLong())), SYNTAX_HIGHLIGHTING_NUMBER).appendSibling(t1); 287 | } 288 | 289 | private static ITextComponent toFormattedComponentShort(NBTTagShort tag, String indentation, int indentDepth) { 290 | //return (new StringTextComponent(String.valueOf(this.data))).appendSibling(itextcomponent).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 291 | ITextComponent t1 = mergeStyle(new TextComponentString("s"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 292 | return mergeStyle(new TextComponentString(String.valueOf(tag.getShort())), SYNTAX_HIGHLIGHTING_NUMBER).appendSibling(t1); 293 | } 294 | 295 | private static ITextComponent toFormattedComponentFloat(NBTTagFloat tag, String indentation, int indentDepth) { 296 | //return (new StringTextComponent(String.valueOf(this.data))).appendSibling(itextcomponent).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 297 | ITextComponent t1 = mergeStyle(new TextComponentString("f"), SYNTAX_HIGHLIGHTING_NUMBER_TYPE); 298 | return mergeStyle(new TextComponentString(String.valueOf(tag.getFloat())), SYNTAX_HIGHLIGHTING_NUMBER).appendSibling(t1); 299 | } 300 | 301 | private static ITextComponent toFormattedComponentInteger(NBTTagInt tag, String indentation, int indentDepth) { 302 | //return (new TextComponentString(tag.toString()).mergeStyle(SYNTAX_HIGHLIGHTING_NUMBER); 303 | return mergeStyle(new TextComponentString(String.valueOf(tag.getInt())), SYNTAX_HIGHLIGHTING_NUMBER); 304 | } 305 | 306 | private static ITextComponent toFormattedComponentString(NBTTagString tag, String indentation, int indentDepth) { 307 | String s = quoteAndEscape(tag.getString()); 308 | String s1 = s.substring(0, 1); 309 | 310 | //ITextComponent itextcomponent = (new TextComponentString(s.substring(1, s.length() - 1))).mergeStyle(SYNTAX_HIGHLIGHTING_STRING); 311 | ITextComponent itextcomponent = mergeStyle((new TextComponentString(s.substring(1, s.length() - 1))), SYNTAX_HIGHLIGHTING_STRING); 312 | return (new TextComponentString(s1)).appendSibling(itextcomponent).appendText(s1); 313 | } 314 | 315 | private static ITextComponent toFormattedComponentCompound(NBTTagCompound tag, String indentation, int indentDepth) { 316 | 317 | Map tagMap = getTagMap(tag); 318 | 319 | if(tagMap == null) { 320 | TextComponentString error = new TextComponentString("Error: tagMap was null"); 321 | error.getStyle().setColor(TextFormatting.RED); 322 | return error; 323 | } 324 | 325 | if (tagMap.isEmpty()) { 326 | return new TextComponentString("{}"); 327 | } else { 328 | TextComponentString iformattabletextcomponent = new TextComponentString("{"); 329 | Collection collection = tagMap.keySet(); 330 | // if (LOGGER.isDebugEnabled()) { 331 | // List list = Lists.newArrayList(tag.tagMap.keySet()); 332 | // Collections.sort(list); 333 | // collection = list; 334 | // } 335 | 336 | if (!indentation.isEmpty()) { 337 | iformattabletextcomponent.appendText("\n"); 338 | } 339 | 340 | ITextComponent iformattabletextcomponent1; 341 | for(Iterator iterator = collection.iterator(); iterator.hasNext(); iformattabletextcomponent.appendSibling(iformattabletextcomponent1)) { 342 | String s = iterator.next(); 343 | 344 | //tagMap.get(s).toFormattedComponent(indentation, indentDepth + 1) 345 | ITextComponent recursiveFormatting = toFormattedComponent(tagMap.get(s), indentation, indentDepth + 1); 346 | 347 | iformattabletextcomponent1 = (new TextComponentString(Strings.repeat(indentation, indentDepth + 1))).appendSibling(getNameComponent(s)).appendText(String.valueOf(':')).appendText(" ").appendSibling(recursiveFormatting); 348 | if (iterator.hasNext()) { 349 | iformattabletextcomponent1.appendText(String.valueOf(',')).appendText(indentation.isEmpty() ? " " : "\n"); 350 | } 351 | } 352 | 353 | if (!indentation.isEmpty()) { 354 | iformattabletextcomponent.appendText("\n").appendText(Strings.repeat(indentation, indentDepth)); 355 | } 356 | 357 | iformattabletextcomponent.appendText("}"); 358 | return iformattabletextcomponent; 359 | } 360 | } 361 | 362 | } 363 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MCP-Snippets 2 | Snippets of code for use in MCP 3 | -------------------------------------------------------------------------------- /SessionChanger/README.md: -------------------------------------------------------------------------------- 1 | # Session Changer 2 | Login to your Minecraft account inside of Eclipse 3 | 4 | ## How to use 5 | ```java 6 | SessionChanger.getInstance().setUser("your-minecraft-account-email@gmail.com", "Sup3RS3curEP@$$w0rDHere!"); 7 | ``` 8 | ## Notes 9 | You will get a error when you paste this class in. I am not going to spoon feed you, but look at the hints your IDE gives you! It will tell you exactly what the issue is. Hint: It is with Minecraft.getMinecraft().session variable -------------------------------------------------------------------------------- /SessionChanger/SessionChanger.java: -------------------------------------------------------------------------------- 1 | import java.util.UUID; 2 | 3 | import com.mojang.authlib.Agent; 4 | import com.mojang.authlib.AuthenticationService; 5 | import com.mojang.authlib.UserAuthentication; 6 | import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; 7 | import com.mojang.util.UUIDTypeAdapter; 8 | import net.minecraft.client.Minecraft; 9 | import net.minecraft.util.Session; 10 | 11 | public class SessionChanger { 12 | 13 | private static SessionChanger instance; 14 | private final UserAuthentication auth; 15 | 16 | public static SessionChanger getInstance() { 17 | if (instance == null) { 18 | instance = new SessionChanger(); 19 | } 20 | 21 | return instance; 22 | } 23 | 24 | //Creates a new Authentication Service. 25 | private SessionChanger() { 26 | UUID notSureWhyINeedThis = UUID.randomUUID(); //Idk, needs a UUID. Seems to be fine making it random 27 | AuthenticationService authService = new YggdrasilAuthenticationService(Minecraft.getMinecraft().getProxy(), notSureWhyINeedThis.toString()); 28 | auth = authService.createUserAuthentication(Agent.MINECRAFT); 29 | authService.createMinecraftSessionService(); 30 | } 31 | 32 | 33 | //Online mode 34 | //Checks if your already loggin in to the account. 35 | public void setUser(String email, String password) { 36 | if(!Minecraft.getMinecraft().getSession().getUsername().equals(email) || Minecraft.getMinecraft().getSession().getToken().equals("0")){ 37 | 38 | this.auth.logOut(); 39 | this.auth.setUsername(email); 40 | this.auth.setPassword(password); 41 | try { 42 | this.auth.logIn(); 43 | Session session = new Session(this.auth.getSelectedProfile().getName(), UUIDTypeAdapter.fromUUID(auth.getSelectedProfile().getId()), this.auth.getAuthenticatedToken(), this.auth.getUserType().getName()); 44 | setSession(session); 45 | } 46 | catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | } 52 | 53 | //Sets the session. 54 | //You need to make this public, and remove the final modifier on the session Object. 55 | private void setSession(Session session) { 56 | Minecraft.getMinecraft().session = session; 57 | } 58 | 59 | //Login offline mode 60 | //Just like MCP does 61 | public void setUserOffline(String username) { 62 | this.auth.logOut(); 63 | Session session = new Session(username, username, "0", "legacy"); 64 | setSession(session); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /SimpleModToggleGui/GuiCheckBox.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.options; 2 | 3 | import java.awt.Color; 4 | 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.FontRenderer; 7 | import net.minecraft.client.gui.GuiButton; 8 | import net.minecraft.client.renderer.GlStateManager; 9 | 10 | public class GuiCheckBox extends GuiButton { 11 | 12 | public boolean checked; 13 | private static final String X = "✗"; 14 | private static final String CHECK = "✔"; 15 | private static final Color X_COLOR = Color.RED; 16 | private static final Color CHECK_COLOR = Color.GREEN; 17 | 18 | public GuiCheckBox(int buttonId, int x, int y) { 19 | this(buttonId, x, y, false); 20 | } 21 | 22 | public GuiCheckBox(int buttonId, int x, int y, boolean checked) { 23 | this(buttonId, x, y, 20, 20, checked); 24 | } 25 | 26 | public GuiCheckBox(int buttonId, int x, int y, int width, int height) { 27 | this(buttonId, x, y, width, height, false); 28 | } 29 | 30 | public GuiCheckBox(int buttonId, int x, int y, int width, int height, boolean checked) { 31 | super(buttonId, x, y, width, height, ""); 32 | this.checked = checked; 33 | } 34 | 35 | @Override 36 | public void drawButton(Minecraft mc, int mouseX, int mouseY) { 37 | if (this.visible) { 38 | FontRenderer fontrenderer = mc.fontRendererObj; 39 | mc.getTextureManager().bindTexture(buttonTextures); 40 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); 41 | this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; 42 | int i = this.getHoverState(this.hovered); 43 | GlStateManager.enableBlend(); 44 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); 45 | GlStateManager.blendFunc(770, 771); 46 | this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + i * 20, this.width / 2, this.height); 47 | this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height); 48 | this.mouseDragged(mc, mouseX, mouseY); 49 | 50 | this.displayString = X; 51 | int color = X_COLOR.getRGB(); 52 | 53 | if(checked) { 54 | this.displayString = CHECK; 55 | color = CHECK_COLOR.getRGB(); 56 | } 57 | 58 | this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, color); 59 | 60 | } 61 | } 62 | 63 | @Override 64 | public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) { 65 | 66 | if(super.mousePressed(mc, mouseX, mouseY)) { 67 | checked = !checked; 68 | return true; 69 | } 70 | 71 | System.out.println(); 72 | 73 | return false; 74 | } 75 | 76 | public boolean isChecked() { 77 | return checked; 78 | } 79 | 80 | public void setChecked(boolean checked) { 81 | this.checked = checked; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /SimpleModToggleGui/GuiModToggle.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.options; 2 | 3 | import java.io.IOException; 4 | 5 | import net.minecraft.client.gui.GuiScreen; 6 | 7 | public class GuiModToggle extends GuiScreen { 8 | 9 | private ScrollListModToggle scrollPanel; 10 | 11 | @Override 12 | public void initGui() { 13 | scrollPanel = new ScrollListModToggle(mc, this); 14 | this.buttonList.clear(); 15 | 16 | } 17 | 18 | @Override 19 | public void handleMouseInput() throws IOException { 20 | super.handleMouseInput(); 21 | this.scrollPanel.handleMouseInput(); 22 | } 23 | 24 | @Override 25 | protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { 26 | this.scrollPanel.mouseClicked(mouseX, mouseY, mouseButton); 27 | super.mouseClicked(mouseX, mouseY, mouseButton); 28 | } 29 | 30 | @Override 31 | protected void mouseReleased(int mouseX, int mouseY, int state) { 32 | this.scrollPanel.mouseReleased(mouseX, mouseY, state); 33 | super.mouseReleased(mouseX, mouseY, state); 34 | } 35 | 36 | @Override 37 | public void drawScreen(int mouseX, int mouseY, float partialTicks) { 38 | this.drawDefaultBackground(); 39 | this.scrollPanel.drawScreen(mouseX, mouseY, partialTicks); 40 | this.drawCenteredString(this.fontRendererObj, "Mod Options", this.width / 2, 8, 16777215); 41 | 42 | super.drawScreen(mouseX, mouseY, partialTicks); 43 | } 44 | 45 | @Override 46 | public boolean doesGuiPauseGame() { 47 | return false; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /SimpleModToggleGui/ModEntry.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.options; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | import clientname.mods.Mod; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.gui.GuiListExtended; 8 | 9 | public class ModEntry implements GuiListExtended.IGuiListEntry, Comparable { 10 | 11 | private final GuiCheckBox checkbox; 12 | private final String name; 13 | private final Mod mod; 14 | private final GuiModToggle gui; 15 | 16 | public ModEntry(GuiModToggle inGui, Mod mod) { 17 | this.mod = mod; 18 | name = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(mod.getClass().getSimpleName().replace("Mod", "").replaceAll("\\d+", "")), " "); 19 | checkbox = new GuiCheckBox(0, 0, 0, mod.isEnabled()); 20 | this.gui = inGui; 21 | } 22 | 23 | @Override 24 | public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) { 25 | this.checkbox.xPosition = x + 200; 26 | this.checkbox.yPosition = y; 27 | this.checkbox.drawButton(Minecraft.getMinecraft(), mouseX, mouseY); 28 | this.mod.setEnabled(this.checkbox.isChecked()); 29 | gui.drawCenteredString(Minecraft.getMinecraft().fontRendererObj, name, x, y + 4, -1); 30 | } 31 | 32 | @Override 33 | public boolean mousePressed(int slotIndex, int x, int y, int p_148278_4_, int p_148278_5_, int p_148278_6_) { 34 | return this.checkbox.mousePressed(Minecraft.getMinecraft(), x, y); 35 | } 36 | 37 | @Override 38 | public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) { 39 | this.checkbox.mouseReleased(x, y); 40 | } 41 | 42 | @Override 43 | public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_) { 44 | 45 | } 46 | 47 | @Override 48 | public int compareTo(ModEntry o) { 49 | return this.name.compareTo(o.name); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /SimpleModToggleGui/README.md: -------------------------------------------------------------------------------- 1 | # Simple Mod GUI 2 | A Super simple and crude Gui for toggling if a mod is enabld or disabled. 3 | No need to add mods, it automatically does it for you. 4 | 5 | Uses [[GuiScrollExample]](https://github.com/egold555/MCP-Snippets/tree/master/GuiScrollExample) and [[GuiCheckBox]](https://github.com/egold555/MCP-Snippets/tree/master/GuiCheckBox) 6 | 7 | # How to use 8 | open "GuiModToggle.java" like any other Gui. 9 | 10 | # Example Sreenshot 11 | ![](https://raw.githubusercontent.com/egold555/MCP-Snippets/master/SimpleModToggleGui/screenshot.png) 12 | -------------------------------------------------------------------------------- /SimpleModToggleGui/ScrollListModToggle.java: -------------------------------------------------------------------------------- 1 | package clientname.gui.options; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import clientname.gui.hud.HUDManager; 8 | import clientname.gui.hud.IRenderer; 9 | import clientname.mods.Mod; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.client.gui.GuiListExtended; 12 | 13 | public class ScrollListModToggle extends GuiListExtended { 14 | 15 | private final List entrys = new ArrayList(); 16 | 17 | public ScrollListModToggle(Minecraft mcIn, GuiModToggle inGui) { 18 | super(mcIn, inGui.width, inGui.height, 63, inGui.height - 32, 20); 19 | for(IRenderer r : HUDManager.getInstance().getRegisteredRenderers()) { 20 | if(r instanceof Mod) { 21 | Mod m = (Mod)r; 22 | entrys.add(new ModEntry(inGui, m)); 23 | } 24 | } 25 | Collections.sort(this.entrys); 26 | } 27 | 28 | @Override 29 | public IGuiListEntry getListEntry(int index) { 30 | return entrys.get(index); 31 | } 32 | 33 | @Override 34 | protected int getSize() { 35 | return entrys.size(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /SimpleModToggleGui/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egold555/MCP-Snippets/c83b6d64628ec0670b9799031cc9787d3dcdf03a/SimpleModToggleGui/screenshot.png -------------------------------------------------------------------------------- /Sounds/README.md: -------------------------------------------------------------------------------- 1 | Sounds.java is most like what you want. 2 | 3 | SoundPrinter.java is the class I wrote to generate Sounds.java -------------------------------------------------------------------------------- /Sounds/SoundPrinter.java: -------------------------------------------------------------------------------- 1 | package YOUR_PACKAGE; 2 | 3 | import java.io.FileNotFoundException; 4 | import java.io.PrintWriter; 5 | import java.util.ArrayList; 6 | import java.util.Arrays; 7 | import java.util.Collections; 8 | import java.util.Comparator; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | import net.minecraft.client.audio.SoundEventAccessorComposite; 14 | import net.minecraft.client.audio.SoundRegistry; 15 | import net.minecraft.util.ResourceLocation; 16 | 17 | //Created by Eric Golde 1/23/2022 18 | public class SoundPrinter { 19 | 20 | //This method should be called from the net.minecraft.client.audio.SoundHandler class 21 | //Place method at the end of the "onResourceManagerReload" function. 22 | //Make sure to remove this method before exporting your client. 23 | public static void print(SoundRegistry registry) { 24 | 25 | //our list of sounds 26 | List soundsRaw = new ArrayList(); 27 | 28 | //Turn resource locations into a list of strings 29 | for(ResourceLocation key : registry.getKeys()) { 30 | soundsRaw.add(key.getResourcePath()); 31 | } 32 | 33 | //sort alphbetically 34 | Collections.sort(soundsRaw); 35 | 36 | //file put in ".minecraft", or "/jars" 37 | try { 38 | PrintWriter pw = new PrintWriter("Sounds.java"); 39 | pw.println("package YOUR_PACKAGE;"); 40 | pw.println(); 41 | pw.println("import net.minecraft.util.ResourceLocation;"); 42 | pw.println(); 43 | pw.println("//Created by Eric Golde: https://github.com/egold555/MCP-Snippets/tree/master/Sounds"); 44 | pw.println("public class Sounds {"); 45 | pw.println(); 46 | for(String s : soundsRaw) { 47 | final String javaVariableName = s.toUpperCase().replace(".", "_"); 48 | pw.println(" public static final ResourceLocation " + javaVariableName + " = new ResourceLocation(\"" + s + "\");"); 49 | } 50 | pw.println(); 51 | pw.println("}"); 52 | pw.close(); 53 | } 54 | catch (FileNotFoundException e) { 55 | e.printStackTrace(); 56 | } 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /Sounds/Sounds.java: -------------------------------------------------------------------------------- 1 | package YOUR_PACKAGE; 2 | 3 | import net.minecraft.util.ResourceLocation; 4 | 5 | //Created by Eric Golde: https://github.com/egold555/MCP-Snippets/tree/master/Sounds 6 | public class Sounds { 7 | 8 | public static final ResourceLocation AMBIENT_CAVE_CAVE = new ResourceLocation("ambient.cave.cave"); 9 | public static final ResourceLocation AMBIENT_WEATHER_RAIN = new ResourceLocation("ambient.weather.rain"); 10 | public static final ResourceLocation AMBIENT_WEATHER_THUNDER = new ResourceLocation("ambient.weather.thunder"); 11 | public static final ResourceLocation CREEPER_PRIMED = new ResourceLocation("creeper.primed"); 12 | public static final ResourceLocation DIG_CLOTH = new ResourceLocation("dig.cloth"); 13 | public static final ResourceLocation DIG_GLASS = new ResourceLocation("dig.glass"); 14 | public static final ResourceLocation DIG_GRASS = new ResourceLocation("dig.grass"); 15 | public static final ResourceLocation DIG_GRAVEL = new ResourceLocation("dig.gravel"); 16 | public static final ResourceLocation DIG_SAND = new ResourceLocation("dig.sand"); 17 | public static final ResourceLocation DIG_SNOW = new ResourceLocation("dig.snow"); 18 | public static final ResourceLocation DIG_STONE = new ResourceLocation("dig.stone"); 19 | public static final ResourceLocation DIG_WOOD = new ResourceLocation("dig.wood"); 20 | public static final ResourceLocation FIRE_FIRE = new ResourceLocation("fire.fire"); 21 | public static final ResourceLocation FIRE_IGNITE = new ResourceLocation("fire.ignite"); 22 | public static final ResourceLocation FIREWORKS_BLAST = new ResourceLocation("fireworks.blast"); 23 | public static final ResourceLocation FIREWORKS_BLAST_FAR = new ResourceLocation("fireworks.blast_far"); 24 | public static final ResourceLocation FIREWORKS_LARGEBLAST = new ResourceLocation("fireworks.largeBlast"); 25 | public static final ResourceLocation FIREWORKS_LARGEBLAST_FAR = new ResourceLocation("fireworks.largeBlast_far"); 26 | public static final ResourceLocation FIREWORKS_LAUNCH = new ResourceLocation("fireworks.launch"); 27 | public static final ResourceLocation FIREWORKS_TWINKLE = new ResourceLocation("fireworks.twinkle"); 28 | public static final ResourceLocation FIREWORKS_TWINKLE_FAR = new ResourceLocation("fireworks.twinkle_far"); 29 | public static final ResourceLocation GAME_HOSTILE_DIE = new ResourceLocation("game.hostile.die"); 30 | public static final ResourceLocation GAME_HOSTILE_HURT = new ResourceLocation("game.hostile.hurt"); 31 | public static final ResourceLocation GAME_HOSTILE_HURT_FALL_BIG = new ResourceLocation("game.hostile.hurt.fall.big"); 32 | public static final ResourceLocation GAME_HOSTILE_HURT_FALL_SMALL = new ResourceLocation("game.hostile.hurt.fall.small"); 33 | public static final ResourceLocation GAME_HOSTILE_SWIM = new ResourceLocation("game.hostile.swim"); 34 | public static final ResourceLocation GAME_HOSTILE_SWIM_SPLASH = new ResourceLocation("game.hostile.swim.splash"); 35 | public static final ResourceLocation GAME_NEUTRAL_DIE = new ResourceLocation("game.neutral.die"); 36 | public static final ResourceLocation GAME_NEUTRAL_HURT = new ResourceLocation("game.neutral.hurt"); 37 | public static final ResourceLocation GAME_NEUTRAL_HURT_FALL_BIG = new ResourceLocation("game.neutral.hurt.fall.big"); 38 | public static final ResourceLocation GAME_NEUTRAL_HURT_FALL_SMALL = new ResourceLocation("game.neutral.hurt.fall.small"); 39 | public static final ResourceLocation GAME_NEUTRAL_SWIM = new ResourceLocation("game.neutral.swim"); 40 | public static final ResourceLocation GAME_NEUTRAL_SWIM_SPLASH = new ResourceLocation("game.neutral.swim.splash"); 41 | public static final ResourceLocation GAME_PLAYER_DIE = new ResourceLocation("game.player.die"); 42 | public static final ResourceLocation GAME_PLAYER_HURT = new ResourceLocation("game.player.hurt"); 43 | public static final ResourceLocation GAME_PLAYER_HURT_FALL_BIG = new ResourceLocation("game.player.hurt.fall.big"); 44 | public static final ResourceLocation GAME_PLAYER_HURT_FALL_SMALL = new ResourceLocation("game.player.hurt.fall.small"); 45 | public static final ResourceLocation GAME_PLAYER_SWIM = new ResourceLocation("game.player.swim"); 46 | public static final ResourceLocation GAME_PLAYER_SWIM_SPLASH = new ResourceLocation("game.player.swim.splash"); 47 | public static final ResourceLocation GAME_POTION_SMASH = new ResourceLocation("game.potion.smash"); 48 | public static final ResourceLocation GAME_TNT_PRIMED = new ResourceLocation("game.tnt.primed"); 49 | public static final ResourceLocation GUI_BUTTON_PRESS = new ResourceLocation("gui.button.press"); 50 | public static final ResourceLocation ITEM_FIRECHARGE_USE = new ResourceLocation("item.fireCharge.use"); 51 | public static final ResourceLocation LIQUID_LAVA = new ResourceLocation("liquid.lava"); 52 | public static final ResourceLocation LIQUID_LAVAPOP = new ResourceLocation("liquid.lavapop"); 53 | public static final ResourceLocation LIQUID_WATER = new ResourceLocation("liquid.water"); 54 | public static final ResourceLocation MINECART_BASE = new ResourceLocation("minecart.base"); 55 | public static final ResourceLocation MINECART_INSIDE = new ResourceLocation("minecart.inside"); 56 | public static final ResourceLocation MOB_BAT_DEATH = new ResourceLocation("mob.bat.death"); 57 | public static final ResourceLocation MOB_BAT_HURT = new ResourceLocation("mob.bat.hurt"); 58 | public static final ResourceLocation MOB_BAT_IDLE = new ResourceLocation("mob.bat.idle"); 59 | public static final ResourceLocation MOB_BAT_LOOP = new ResourceLocation("mob.bat.loop"); 60 | public static final ResourceLocation MOB_BAT_TAKEOFF = new ResourceLocation("mob.bat.takeoff"); 61 | public static final ResourceLocation MOB_BLAZE_BREATHE = new ResourceLocation("mob.blaze.breathe"); 62 | public static final ResourceLocation MOB_BLAZE_DEATH = new ResourceLocation("mob.blaze.death"); 63 | public static final ResourceLocation MOB_BLAZE_HIT = new ResourceLocation("mob.blaze.hit"); 64 | public static final ResourceLocation MOB_CAT_HISS = new ResourceLocation("mob.cat.hiss"); 65 | public static final ResourceLocation MOB_CAT_HITT = new ResourceLocation("mob.cat.hitt"); 66 | public static final ResourceLocation MOB_CAT_MEOW = new ResourceLocation("mob.cat.meow"); 67 | public static final ResourceLocation MOB_CAT_PURR = new ResourceLocation("mob.cat.purr"); 68 | public static final ResourceLocation MOB_CAT_PURREOW = new ResourceLocation("mob.cat.purreow"); 69 | public static final ResourceLocation MOB_CHICKEN_HURT = new ResourceLocation("mob.chicken.hurt"); 70 | public static final ResourceLocation MOB_CHICKEN_PLOP = new ResourceLocation("mob.chicken.plop"); 71 | public static final ResourceLocation MOB_CHICKEN_SAY = new ResourceLocation("mob.chicken.say"); 72 | public static final ResourceLocation MOB_CHICKEN_STEP = new ResourceLocation("mob.chicken.step"); 73 | public static final ResourceLocation MOB_COW_HURT = new ResourceLocation("mob.cow.hurt"); 74 | public static final ResourceLocation MOB_COW_SAY = new ResourceLocation("mob.cow.say"); 75 | public static final ResourceLocation MOB_COW_STEP = new ResourceLocation("mob.cow.step"); 76 | public static final ResourceLocation MOB_CREEPER_DEATH = new ResourceLocation("mob.creeper.death"); 77 | public static final ResourceLocation MOB_CREEPER_SAY = new ResourceLocation("mob.creeper.say"); 78 | public static final ResourceLocation MOB_ENDERDRAGON_END = new ResourceLocation("mob.enderdragon.end"); 79 | public static final ResourceLocation MOB_ENDERDRAGON_GROWL = new ResourceLocation("mob.enderdragon.growl"); 80 | public static final ResourceLocation MOB_ENDERDRAGON_HIT = new ResourceLocation("mob.enderdragon.hit"); 81 | public static final ResourceLocation MOB_ENDERDRAGON_WINGS = new ResourceLocation("mob.enderdragon.wings"); 82 | public static final ResourceLocation MOB_ENDERMEN_DEATH = new ResourceLocation("mob.endermen.death"); 83 | public static final ResourceLocation MOB_ENDERMEN_HIT = new ResourceLocation("mob.endermen.hit"); 84 | public static final ResourceLocation MOB_ENDERMEN_IDLE = new ResourceLocation("mob.endermen.idle"); 85 | public static final ResourceLocation MOB_ENDERMEN_PORTAL = new ResourceLocation("mob.endermen.portal"); 86 | public static final ResourceLocation MOB_ENDERMEN_SCREAM = new ResourceLocation("mob.endermen.scream"); 87 | public static final ResourceLocation MOB_ENDERMEN_STARE = new ResourceLocation("mob.endermen.stare"); 88 | public static final ResourceLocation MOB_GHAST_AFFECTIONATE_SCREAM = new ResourceLocation("mob.ghast.affectionate_scream"); 89 | public static final ResourceLocation MOB_GHAST_CHARGE = new ResourceLocation("mob.ghast.charge"); 90 | public static final ResourceLocation MOB_GHAST_DEATH = new ResourceLocation("mob.ghast.death"); 91 | public static final ResourceLocation MOB_GHAST_FIREBALL = new ResourceLocation("mob.ghast.fireball"); 92 | public static final ResourceLocation MOB_GHAST_MOAN = new ResourceLocation("mob.ghast.moan"); 93 | public static final ResourceLocation MOB_GHAST_SCREAM = new ResourceLocation("mob.ghast.scream"); 94 | public static final ResourceLocation MOB_GUARDIAN_ATTACK = new ResourceLocation("mob.guardian.attack"); 95 | public static final ResourceLocation MOB_GUARDIAN_CURSE = new ResourceLocation("mob.guardian.curse"); 96 | public static final ResourceLocation MOB_GUARDIAN_DEATH = new ResourceLocation("mob.guardian.death"); 97 | public static final ResourceLocation MOB_GUARDIAN_ELDER_DEATH = new ResourceLocation("mob.guardian.elder.death"); 98 | public static final ResourceLocation MOB_GUARDIAN_ELDER_HIT = new ResourceLocation("mob.guardian.elder.hit"); 99 | public static final ResourceLocation MOB_GUARDIAN_ELDER_IDLE = new ResourceLocation("mob.guardian.elder.idle"); 100 | public static final ResourceLocation MOB_GUARDIAN_FLOP = new ResourceLocation("mob.guardian.flop"); 101 | public static final ResourceLocation MOB_GUARDIAN_HIT = new ResourceLocation("mob.guardian.hit"); 102 | public static final ResourceLocation MOB_GUARDIAN_IDLE = new ResourceLocation("mob.guardian.idle"); 103 | public static final ResourceLocation MOB_GUARDIAN_LAND_DEATH = new ResourceLocation("mob.guardian.land.death"); 104 | public static final ResourceLocation MOB_GUARDIAN_LAND_HIT = new ResourceLocation("mob.guardian.land.hit"); 105 | public static final ResourceLocation MOB_GUARDIAN_LAND_IDLE = new ResourceLocation("mob.guardian.land.idle"); 106 | public static final ResourceLocation MOB_HORSE_ANGRY = new ResourceLocation("mob.horse.angry"); 107 | public static final ResourceLocation MOB_HORSE_ARMOR = new ResourceLocation("mob.horse.armor"); 108 | public static final ResourceLocation MOB_HORSE_BREATHE = new ResourceLocation("mob.horse.breathe"); 109 | public static final ResourceLocation MOB_HORSE_DEATH = new ResourceLocation("mob.horse.death"); 110 | public static final ResourceLocation MOB_HORSE_DONKEY_ANGRY = new ResourceLocation("mob.horse.donkey.angry"); 111 | public static final ResourceLocation MOB_HORSE_DONKEY_DEATH = new ResourceLocation("mob.horse.donkey.death"); 112 | public static final ResourceLocation MOB_HORSE_DONKEY_HIT = new ResourceLocation("mob.horse.donkey.hit"); 113 | public static final ResourceLocation MOB_HORSE_DONKEY_IDLE = new ResourceLocation("mob.horse.donkey.idle"); 114 | public static final ResourceLocation MOB_HORSE_GALLOP = new ResourceLocation("mob.horse.gallop"); 115 | public static final ResourceLocation MOB_HORSE_HIT = new ResourceLocation("mob.horse.hit"); 116 | public static final ResourceLocation MOB_HORSE_IDLE = new ResourceLocation("mob.horse.idle"); 117 | public static final ResourceLocation MOB_HORSE_JUMP = new ResourceLocation("mob.horse.jump"); 118 | public static final ResourceLocation MOB_HORSE_LAND = new ResourceLocation("mob.horse.land"); 119 | public static final ResourceLocation MOB_HORSE_LEATHER = new ResourceLocation("mob.horse.leather"); 120 | public static final ResourceLocation MOB_HORSE_SKELETON_DEATH = new ResourceLocation("mob.horse.skeleton.death"); 121 | public static final ResourceLocation MOB_HORSE_SKELETON_HIT = new ResourceLocation("mob.horse.skeleton.hit"); 122 | public static final ResourceLocation MOB_HORSE_SKELETON_IDLE = new ResourceLocation("mob.horse.skeleton.idle"); 123 | public static final ResourceLocation MOB_HORSE_SOFT = new ResourceLocation("mob.horse.soft"); 124 | public static final ResourceLocation MOB_HORSE_WOOD = new ResourceLocation("mob.horse.wood"); 125 | public static final ResourceLocation MOB_HORSE_ZOMBIE_DEATH = new ResourceLocation("mob.horse.zombie.death"); 126 | public static final ResourceLocation MOB_HORSE_ZOMBIE_HIT = new ResourceLocation("mob.horse.zombie.hit"); 127 | public static final ResourceLocation MOB_HORSE_ZOMBIE_IDLE = new ResourceLocation("mob.horse.zombie.idle"); 128 | public static final ResourceLocation MOB_IRONGOLEM_DEATH = new ResourceLocation("mob.irongolem.death"); 129 | public static final ResourceLocation MOB_IRONGOLEM_HIT = new ResourceLocation("mob.irongolem.hit"); 130 | public static final ResourceLocation MOB_IRONGOLEM_THROW = new ResourceLocation("mob.irongolem.throw"); 131 | public static final ResourceLocation MOB_IRONGOLEM_WALK = new ResourceLocation("mob.irongolem.walk"); 132 | public static final ResourceLocation MOB_MAGMACUBE_BIG = new ResourceLocation("mob.magmacube.big"); 133 | public static final ResourceLocation MOB_MAGMACUBE_JUMP = new ResourceLocation("mob.magmacube.jump"); 134 | public static final ResourceLocation MOB_MAGMACUBE_SMALL = new ResourceLocation("mob.magmacube.small"); 135 | public static final ResourceLocation MOB_PIG_DEATH = new ResourceLocation("mob.pig.death"); 136 | public static final ResourceLocation MOB_PIG_SAY = new ResourceLocation("mob.pig.say"); 137 | public static final ResourceLocation MOB_PIG_STEP = new ResourceLocation("mob.pig.step"); 138 | public static final ResourceLocation MOB_RABBIT_DEATH = new ResourceLocation("mob.rabbit.death"); 139 | public static final ResourceLocation MOB_RABBIT_HOP = new ResourceLocation("mob.rabbit.hop"); 140 | public static final ResourceLocation MOB_RABBIT_HURT = new ResourceLocation("mob.rabbit.hurt"); 141 | public static final ResourceLocation MOB_RABBIT_IDLE = new ResourceLocation("mob.rabbit.idle"); 142 | public static final ResourceLocation MOB_SHEEP_SAY = new ResourceLocation("mob.sheep.say"); 143 | public static final ResourceLocation MOB_SHEEP_SHEAR = new ResourceLocation("mob.sheep.shear"); 144 | public static final ResourceLocation MOB_SHEEP_STEP = new ResourceLocation("mob.sheep.step"); 145 | public static final ResourceLocation MOB_SILVERFISH_HIT = new ResourceLocation("mob.silverfish.hit"); 146 | public static final ResourceLocation MOB_SILVERFISH_KILL = new ResourceLocation("mob.silverfish.kill"); 147 | public static final ResourceLocation MOB_SILVERFISH_SAY = new ResourceLocation("mob.silverfish.say"); 148 | public static final ResourceLocation MOB_SILVERFISH_STEP = new ResourceLocation("mob.silverfish.step"); 149 | public static final ResourceLocation MOB_SKELETON_DEATH = new ResourceLocation("mob.skeleton.death"); 150 | public static final ResourceLocation MOB_SKELETON_HURT = new ResourceLocation("mob.skeleton.hurt"); 151 | public static final ResourceLocation MOB_SKELETON_SAY = new ResourceLocation("mob.skeleton.say"); 152 | public static final ResourceLocation MOB_SKELETON_STEP = new ResourceLocation("mob.skeleton.step"); 153 | public static final ResourceLocation MOB_SLIME_ATTACK = new ResourceLocation("mob.slime.attack"); 154 | public static final ResourceLocation MOB_SLIME_BIG = new ResourceLocation("mob.slime.big"); 155 | public static final ResourceLocation MOB_SLIME_SMALL = new ResourceLocation("mob.slime.small"); 156 | public static final ResourceLocation MOB_SPIDER_DEATH = new ResourceLocation("mob.spider.death"); 157 | public static final ResourceLocation MOB_SPIDER_SAY = new ResourceLocation("mob.spider.say"); 158 | public static final ResourceLocation MOB_SPIDER_STEP = new ResourceLocation("mob.spider.step"); 159 | public static final ResourceLocation MOB_VILLAGER_DEATH = new ResourceLocation("mob.villager.death"); 160 | public static final ResourceLocation MOB_VILLAGER_HAGGLE = new ResourceLocation("mob.villager.haggle"); 161 | public static final ResourceLocation MOB_VILLAGER_HIT = new ResourceLocation("mob.villager.hit"); 162 | public static final ResourceLocation MOB_VILLAGER_IDLE = new ResourceLocation("mob.villager.idle"); 163 | public static final ResourceLocation MOB_VILLAGER_NO = new ResourceLocation("mob.villager.no"); 164 | public static final ResourceLocation MOB_VILLAGER_YES = new ResourceLocation("mob.villager.yes"); 165 | public static final ResourceLocation MOB_WITHER_DEATH = new ResourceLocation("mob.wither.death"); 166 | public static final ResourceLocation MOB_WITHER_HURT = new ResourceLocation("mob.wither.hurt"); 167 | public static final ResourceLocation MOB_WITHER_IDLE = new ResourceLocation("mob.wither.idle"); 168 | public static final ResourceLocation MOB_WITHER_SHOOT = new ResourceLocation("mob.wither.shoot"); 169 | public static final ResourceLocation MOB_WITHER_SPAWN = new ResourceLocation("mob.wither.spawn"); 170 | public static final ResourceLocation MOB_WOLF_BARK = new ResourceLocation("mob.wolf.bark"); 171 | public static final ResourceLocation MOB_WOLF_DEATH = new ResourceLocation("mob.wolf.death"); 172 | public static final ResourceLocation MOB_WOLF_GROWL = new ResourceLocation("mob.wolf.growl"); 173 | public static final ResourceLocation MOB_WOLF_HOWL = new ResourceLocation("mob.wolf.howl"); 174 | public static final ResourceLocation MOB_WOLF_HURT = new ResourceLocation("mob.wolf.hurt"); 175 | public static final ResourceLocation MOB_WOLF_PANTING = new ResourceLocation("mob.wolf.panting"); 176 | public static final ResourceLocation MOB_WOLF_SHAKE = new ResourceLocation("mob.wolf.shake"); 177 | public static final ResourceLocation MOB_WOLF_STEP = new ResourceLocation("mob.wolf.step"); 178 | public static final ResourceLocation MOB_WOLF_WHINE = new ResourceLocation("mob.wolf.whine"); 179 | public static final ResourceLocation MOB_ZOMBIE_DEATH = new ResourceLocation("mob.zombie.death"); 180 | public static final ResourceLocation MOB_ZOMBIE_HURT = new ResourceLocation("mob.zombie.hurt"); 181 | public static final ResourceLocation MOB_ZOMBIE_INFECT = new ResourceLocation("mob.zombie.infect"); 182 | public static final ResourceLocation MOB_ZOMBIE_METAL = new ResourceLocation("mob.zombie.metal"); 183 | public static final ResourceLocation MOB_ZOMBIE_REMEDY = new ResourceLocation("mob.zombie.remedy"); 184 | public static final ResourceLocation MOB_ZOMBIE_SAY = new ResourceLocation("mob.zombie.say"); 185 | public static final ResourceLocation MOB_ZOMBIE_STEP = new ResourceLocation("mob.zombie.step"); 186 | public static final ResourceLocation MOB_ZOMBIE_UNFECT = new ResourceLocation("mob.zombie.unfect"); 187 | public static final ResourceLocation MOB_ZOMBIE_WOOD = new ResourceLocation("mob.zombie.wood"); 188 | public static final ResourceLocation MOB_ZOMBIE_WOODBREAK = new ResourceLocation("mob.zombie.woodbreak"); 189 | public static final ResourceLocation MOB_ZOMBIEPIG_ZPIG = new ResourceLocation("mob.zombiepig.zpig"); 190 | public static final ResourceLocation MOB_ZOMBIEPIG_ZPIGANGRY = new ResourceLocation("mob.zombiepig.zpigangry"); 191 | public static final ResourceLocation MOB_ZOMBIEPIG_ZPIGDEATH = new ResourceLocation("mob.zombiepig.zpigdeath"); 192 | public static final ResourceLocation MOB_ZOMBIEPIG_ZPIGHURT = new ResourceLocation("mob.zombiepig.zpighurt"); 193 | public static final ResourceLocation MUSIC_GAME = new ResourceLocation("music.game"); 194 | public static final ResourceLocation MUSIC_GAME_CREATIVE = new ResourceLocation("music.game.creative"); 195 | public static final ResourceLocation MUSIC_GAME_END = new ResourceLocation("music.game.end"); 196 | public static final ResourceLocation MUSIC_GAME_END_CREDITS = new ResourceLocation("music.game.end.credits"); 197 | public static final ResourceLocation MUSIC_GAME_END_DRAGON = new ResourceLocation("music.game.end.dragon"); 198 | public static final ResourceLocation MUSIC_GAME_NETHER = new ResourceLocation("music.game.nether"); 199 | public static final ResourceLocation MUSIC_MENU = new ResourceLocation("music.menu"); 200 | public static final ResourceLocation NOTE_BASS = new ResourceLocation("note.bass"); 201 | public static final ResourceLocation NOTE_BASSATTACK = new ResourceLocation("note.bassattack"); 202 | public static final ResourceLocation NOTE_BD = new ResourceLocation("note.bd"); 203 | public static final ResourceLocation NOTE_HARP = new ResourceLocation("note.harp"); 204 | public static final ResourceLocation NOTE_HAT = new ResourceLocation("note.hat"); 205 | public static final ResourceLocation NOTE_PLING = new ResourceLocation("note.pling"); 206 | public static final ResourceLocation NOTE_SNARE = new ResourceLocation("note.snare"); 207 | public static final ResourceLocation PORTAL_PORTAL = new ResourceLocation("portal.portal"); 208 | public static final ResourceLocation PORTAL_TRAVEL = new ResourceLocation("portal.travel"); 209 | public static final ResourceLocation PORTAL_TRIGGER = new ResourceLocation("portal.trigger"); 210 | public static final ResourceLocation RANDOM_ANVIL_BREAK = new ResourceLocation("random.anvil_break"); 211 | public static final ResourceLocation RANDOM_ANVIL_LAND = new ResourceLocation("random.anvil_land"); 212 | public static final ResourceLocation RANDOM_ANVIL_USE = new ResourceLocation("random.anvil_use"); 213 | public static final ResourceLocation RANDOM_BOW = new ResourceLocation("random.bow"); 214 | public static final ResourceLocation RANDOM_BOWHIT = new ResourceLocation("random.bowhit"); 215 | public static final ResourceLocation RANDOM_BREAK = new ResourceLocation("random.break"); 216 | public static final ResourceLocation RANDOM_BURP = new ResourceLocation("random.burp"); 217 | public static final ResourceLocation RANDOM_CHESTCLOSED = new ResourceLocation("random.chestclosed"); 218 | public static final ResourceLocation RANDOM_CHESTOPEN = new ResourceLocation("random.chestopen"); 219 | public static final ResourceLocation RANDOM_CLICK = new ResourceLocation("random.click"); 220 | public static final ResourceLocation RANDOM_DOOR_CLOSE = new ResourceLocation("random.door_close"); 221 | public static final ResourceLocation RANDOM_DOOR_OPEN = new ResourceLocation("random.door_open"); 222 | public static final ResourceLocation RANDOM_DRINK = new ResourceLocation("random.drink"); 223 | public static final ResourceLocation RANDOM_EAT = new ResourceLocation("random.eat"); 224 | public static final ResourceLocation RANDOM_EXPLODE = new ResourceLocation("random.explode"); 225 | public static final ResourceLocation RANDOM_FIZZ = new ResourceLocation("random.fizz"); 226 | public static final ResourceLocation RANDOM_LEVELUP = new ResourceLocation("random.levelup"); 227 | public static final ResourceLocation RANDOM_ORB = new ResourceLocation("random.orb"); 228 | public static final ResourceLocation RANDOM_POP = new ResourceLocation("random.pop"); 229 | public static final ResourceLocation RANDOM_SPLASH = new ResourceLocation("random.splash"); 230 | public static final ResourceLocation RANDOM_SUCCESSFUL_HIT = new ResourceLocation("random.successful_hit"); 231 | public static final ResourceLocation RANDOM_WOOD_CLICK = new ResourceLocation("random.wood_click"); 232 | public static final ResourceLocation RECORDS_11 = new ResourceLocation("records.11"); 233 | public static final ResourceLocation RECORDS_13 = new ResourceLocation("records.13"); 234 | public static final ResourceLocation RECORDS_BLOCKS = new ResourceLocation("records.blocks"); 235 | public static final ResourceLocation RECORDS_CAT = new ResourceLocation("records.cat"); 236 | public static final ResourceLocation RECORDS_CHIRP = new ResourceLocation("records.chirp"); 237 | public static final ResourceLocation RECORDS_FAR = new ResourceLocation("records.far"); 238 | public static final ResourceLocation RECORDS_MALL = new ResourceLocation("records.mall"); 239 | public static final ResourceLocation RECORDS_MELLOHI = new ResourceLocation("records.mellohi"); 240 | public static final ResourceLocation RECORDS_STAL = new ResourceLocation("records.stal"); 241 | public static final ResourceLocation RECORDS_STRAD = new ResourceLocation("records.strad"); 242 | public static final ResourceLocation RECORDS_WAIT = new ResourceLocation("records.wait"); 243 | public static final ResourceLocation RECORDS_WARD = new ResourceLocation("records.ward"); 244 | public static final ResourceLocation STEP_CLOTH = new ResourceLocation("step.cloth"); 245 | public static final ResourceLocation STEP_GRASS = new ResourceLocation("step.grass"); 246 | public static final ResourceLocation STEP_GRAVEL = new ResourceLocation("step.gravel"); 247 | public static final ResourceLocation STEP_LADDER = new ResourceLocation("step.ladder"); 248 | public static final ResourceLocation STEP_SAND = new ResourceLocation("step.sand"); 249 | public static final ResourceLocation STEP_SNOW = new ResourceLocation("step.snow"); 250 | public static final ResourceLocation STEP_STONE = new ResourceLocation("step.stone"); 251 | public static final ResourceLocation STEP_WOOD = new ResourceLocation("step.wood"); 252 | public static final ResourceLocation TILE_PISTON_IN = new ResourceLocation("tile.piston.in"); 253 | public static final ResourceLocation TILE_PISTON_OUT = new ResourceLocation("tile.piston.out"); 254 | 255 | } 256 | -------------------------------------------------------------------------------- /UrlTextureUtil/ModUrlImageTest.java: -------------------------------------------------------------------------------- 1 | package ; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | //change these to your client packages... 6 | import clientname.module.ModuleDraggable; 7 | import clientname.render.draghud.util.ScreenPosition; 8 | import clientname.utils.UrlTextureUtil; 9 | import clientname.utils.UrlTextureUtil.ResourceLocationCallback; 10 | 11 | import net.minecraft.client.gui.Gui; 12 | import net.minecraft.client.renderer.texture.DynamicTexture; 13 | import net.minecraft.client.renderer.texture.TextureUtil; 14 | import net.minecraft.util.ResourceLocation; 15 | 16 | public class ModUrlImageTest extends ModDraggable { 17 | 18 | private ResourceLocation img = null; 19 | private boolean hasTriedToDownload = false; 20 | 21 | @Override 22 | public int getHeight() { 23 | return 100; 24 | } 25 | 26 | @Override 27 | public int getWidth() { 28 | return 100; 29 | } 30 | 31 | @Override 32 | public void render(ScreenPosition pos) { 33 | 34 | if(img == null && !hasTriedToDownload) { 35 | hasTriedToDownload = true; 36 | UrlTextureUtil.downloadAndSetTexture("https://flif.info/example-images/fish.png", new ResourceLocationCallback() { 37 | 38 | @Override 39 | public void onTextureLoaded(ResourceLocation rl) { 40 | img = rl; 41 | } 42 | }); 43 | } 44 | 45 | if(img != null) { 46 | GL11.glPushMatrix(); 47 | mc.getTextureManager().bindTexture(img); 48 | Gui.drawModalRectWithCustomSizedTexture(pos.getAbsoluteX(), pos.getAbsoluteY(), 1, 1, 100, 100, 100, 100); 49 | GL11.glPopMatrix(); 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /UrlTextureUtil/README.md: -------------------------------------------------------------------------------- 1 | # UrlTextureUtil 2 | An adaptation to ThreadDownloadImage with a resource location callback 3 | 4 | # How to use 5 | ```java 6 | UrlTextureUtil.downloadAndSetTexture("https://your-url-here.com/cool-image.png", new ResourceLocationCallback() { 7 | @Override 8 | public void onTextureLoaded(ResourceLocation rl) { 9 | //rl is the downloaded textur as a resource location. 10 | } 11 | }); 12 | ``` 13 | I have also put an example mod that Displays a fish image -------------------------------------------------------------------------------- /UrlTextureUtil/UrlTextureUtil.java: -------------------------------------------------------------------------------- 1 | package clientname.utils; 2 | 3 | import java.awt.image.BufferedImage; 4 | 5 | import org.apache.commons.io.FilenameUtils; 6 | 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.client.renderer.IImageBuffer; 9 | import net.minecraft.client.renderer.ImageBufferDownload; 10 | import net.minecraft.client.renderer.ThreadDownloadImageData; 11 | import net.minecraft.client.renderer.texture.ITextureObject; 12 | import net.minecraft.client.renderer.texture.TextureManager; 13 | import net.minecraft.util.ResourceLocation; 14 | 15 | public class UrlTextureUtil 16 | { 17 | public static void downloadAndSetTexture(String url, ResourceLocationCallback callback) 18 | { 19 | 20 | if (url != null && !url.isEmpty()) 21 | { 22 | String baseName = FilenameUtils.getBaseName(url); 23 | final ResourceLocation resourcelocation = new ResourceLocation("clientname_temp/" + baseName); 24 | TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); 25 | ITextureObject itextureobject = texturemanager.getTexture(resourcelocation); 26 | 27 | if (itextureobject != null && itextureobject instanceof ThreadDownloadImageData) 28 | { 29 | ThreadDownloadImageData threaddownloadimagedata = (ThreadDownloadImageData)itextureobject; 30 | 31 | if (threaddownloadimagedata.imageFound != null) 32 | { 33 | if (threaddownloadimagedata.imageFound.booleanValue()) 34 | { 35 | callback.onTextureLoaded(resourcelocation); 36 | } 37 | 38 | return; 39 | } 40 | } 41 | 42 | IImageBuffer iimagebuffer = new IImageBuffer() 43 | { 44 | ImageBufferDownload ibd = new ImageBufferDownload(); 45 | public BufferedImage parseUserSkin(BufferedImage image) 46 | { 47 | return image; 48 | } 49 | public void skinAvailable() 50 | { 51 | callback.onTextureLoaded(resourcelocation); 52 | } 53 | }; 54 | ThreadDownloadImageData threaddownloadimagedata1 = new ThreadDownloadImageData(null, url, null, iimagebuffer); 55 | threaddownloadimagedata1.pipeline = true; 56 | texturemanager.loadTexture(resourcelocation, threaddownloadimagedata1); 57 | } 58 | } 59 | 60 | public interface ResourceLocationCallback { 61 | public void onTextureLoaded(ResourceLocation rl); 62 | } 63 | 64 | } 65 | --------------------------------------------------------------------------------