Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
added cape stuff from gti/gt4r to de-duplicate it
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Apr 17, 2024
1 parent 47e7462 commit 59f5d80
Show file tree
Hide file tree
Showing 16 changed files with 429 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.github.gregtechintergalactical.gtcore.network.MessageCraftingSync;
import io.github.gregtechintergalactical.gtcore.network.MessageInventorySync;
import io.github.gregtechintergalactical.gtcore.network.MessageTriggerInventorySync;
import io.github.gregtechintergalactical.gtcore.proxy.CommonHandler;
import io.github.gregtechintergalactical.gtcore.tree.RubberTree;
import io.github.gregtechintergalactical.gtcore.tree.RubberTreeWorldGen;
import muramasa.antimatter.AntimatterAPI;
Expand Down Expand Up @@ -92,6 +93,7 @@ public void onRegistrationEvent(RegistrationEvent event, Side side) {
case DATA_INIT -> {
SlotTypes.init();
MenuHandlers.init();
GTCoreData.init();
GTCoreBlocks.init();
GTCoreItems.init();
GTCoreFluids.init();
Expand All @@ -114,6 +116,7 @@ public void onRegistrationEvent(RegistrationEvent event, Side side) {
case DATA_READY -> {
WoodType.register(GTCoreBlocks.RUBBER_WOOD_TYPE);
GTCoreRemapping.init();
CommonHandler.setup();
AntimatterJEIREIPlugin.addItemsToHide(l -> {
l.add(AntimatterAPI.get(IAntimatterTool.class, "electric_wrench_alt_lv").getItem());
l.add(AntimatterAPI.get(IAntimatterTool.class, "electric_wrench_alt_mv").getItem());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.gregtechintergalactical.gtcore.data;

import io.github.gregtechintergalactical.gtcore.GTCore;
import net.minecraft.resources.ResourceLocation;

import java.util.HashSet;
import java.util.Set;

public class GTCoreData {
private static final String CAPE_PATH = "textures/capes/";
public static final ResourceLocation[] CAPE_LOCATIONS = new ResourceLocation[] {new ResourceLocation(GTCore.ID, CAPE_PATH + "braintech.png"), new ResourceLocation(GTCore.ID, CAPE_PATH + "silver.png"), new ResourceLocation(GTCore.ID, CAPE_PATH + "mrbrain.png"), new ResourceLocation(GTCore.ID, CAPE_PATH + "dev.png"), new ResourceLocation(GTCore.ID, CAPE_PATH + "gold.png"), new ResourceLocation(GTCore.ID, CAPE_PATH + "crazy.png"), new ResourceLocation(GTCore.ID, CAPE_PATH + "fake.png")};

public static final Set<String> SupporterListSilver = new HashSet<>(), SupporterListGold = new HashSet<>();

public static void init(){

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.gregtechintergalactical.gtcore.mixin;

import com.mojang.authlib.GameProfile;
import io.github.gregtechintergalactical.gtcore.data.GTCoreData;
import muramasa.antimatter.util.AntimatterPlatformUtils;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;

@Mixin(AbstractClientPlayer.class)
public abstract class AbstractClientPlayerEntityMixin extends Player {

public AbstractClientPlayerEntityMixin(Level p_i241920_1_, BlockPos p_i241920_2_, float p_i241920_3_, GameProfile p_i241920_4_) {
super(p_i241920_1_, p_i241920_2_, p_i241920_3_, p_i241920_4_);
}

@Inject(method = "getCloakTextureLocation", at = @At(value = "HEAD"), cancellable = true)
private void getLocationGTCape(CallbackInfoReturnable<ResourceLocation> info){
String playerName = this.getDisplayName().getString();
if (!AntimatterPlatformUtils.isProduction()) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[3]);
if (orString(playerName, "GregoriusT", "OvermindDL1", "jihuayu123", "Yuesha_Kev14", "Evanvenir", "Trinsdar")) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[3]);
if (playerName.equals("CrazyJ1984")) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[5]);
if (playerName.equals("Mr_Brain")) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[2]);
if (playerName.equals("Friedi4321")) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[0]);
if (GTCoreData.SupporterListGold.contains(playerName)) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[4]);
if (GTCoreData.SupporterListSilver.contains(playerName)) info.setReturnValue(GTCoreData.CAPE_LOCATIONS[1]);
}

private boolean orString(String compare, String... strings){
List<String> list = List.of(strings);
return list.contains(compare);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.github.gregtechintergalactical.gtcore.proxy;

import io.github.gregtechintergalactical.gtcore.GTCore;
import net.minecraft.core.NonNullList;

import java.net.URL;
import java.util.List;
import java.util.Scanner;

import static io.github.gregtechintergalactical.gtcore.data.GTCoreData.SupporterListGold;
import static io.github.gregtechintergalactical.gtcore.data.GTCoreData.SupporterListSilver;

public class CommonHandler {
public static void setup(){
new Thread(() -> {

List<String>
tTextFile = downloadTextFile("updates.gregtech.mechaenetia.com/com/gregoriust/gregtech/supporterlist.txt", false);
if (tTextFile != null && tTextFile.size() > 3) {
SupporterListSilver.addAll(tTextFile);
} else try {
Scanner tScanner = new Scanner(GTCore.class.getResourceAsStream("/supporterlist.txt"));
while (tScanner.hasNextLine()) SupporterListSilver.add(tScanner.nextLine().toLowerCase());
tScanner.close();
GTCore.LOGGER.warn("GT_DL_Thread: Failed downloading Silver Supporter List, using interal List!");
} catch(Throwable exc) {exc.printStackTrace();}

tTextFile = downloadTextFile("updates.gregtech.mechaenetia.com/com/gregoriust/gregtech/supporterlistgold.txt", false);
if (tTextFile != null && tTextFile.size() > 3) {
SupporterListGold.addAll(tTextFile);
} else try {
Scanner tScanner = new Scanner(GTCore.class.getResourceAsStream("/supporterlistgold.txt"));
while (tScanner.hasNextLine()) SupporterListGold.add(tScanner.nextLine().toLowerCase());
tScanner.close();
GTCore.LOGGER.warn("GT_DL_Thread: Failed downloading Gold Supporter List, using interal List!");
} catch(Throwable exc) {exc.printStackTrace();}

SupporterListSilver.removeAll(SupporterListGold);

}).start();
}

protected static List<String> downloadTextFile(String aURL, boolean aLowercase) {
List<String> rList = NonNullList.create();
try {
Scanner tScanner = new Scanner(new URL(aURL.startsWith("http")?aURL:"https://"+aURL).openStream());
while (tScanner.hasNextLine()) rList.add(aLowercase ? tScanner.nextLine().toLowerCase() : tScanner.nextLine());
tScanner.close();
for (String tLine : rList) if (tLine.contains("a href")) {
GTCore.LOGGER.error("GT_DL_Thread: Your Internet Connection has Issues, you should probably go check that your ISP or Network don't do stupid Stuff.");
return NonNullList.create();
}
return rList;
} catch(Throwable f) {
GTCore.LOGGER.error("GT_DL_Thread: Failed to Connect.");
}
return null;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions common/src/main/resources/gtcore.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"MixinBlock",
"MixinComposterBlock",
"MixinMerchantOffer"
],
"client": [
"AbstractClientPlayerEntityMixin"
]
}
Loading

0 comments on commit 59f5d80

Please sign in to comment.