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

Commit

Permalink
added capes
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 7, 2023
1 parent 7811fb3 commit b5a1eda
Show file tree
Hide file tree
Showing 20 changed files with 485 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/src/main/java/muramasa/gregtech/GregTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import muramasa.gregtech.loader.machines.generator.Fuels;
import muramasa.gregtech.loader.machines.generator.LargeBoilerLoader;
import muramasa.gregtech.loader.multi.*;
import muramasa.gregtech.proxy.CommonHandler;
import muramasa.gregtech.proxy.ServerHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -174,6 +175,7 @@ public void onRegistrationEvent(RegistrationEvent event, Side side) {
l.addAll(Arrays.asList(CircuitBasicIntegrated, CircuitGoodIntegrated, CircuitWetware, MicroProcessor, IntegratedProcessor, NanoProcessor, QuantumProcessor));
}
});
AntimatterAPI.runLaterCommon(CommonHandler::setup);
// if (side == Dist.CLIENT) StructureInfo.init();
TierMaps.providerInit();
}
Expand Down
9 changes: 9 additions & 0 deletions common/src/main/java/muramasa/gregtech/data/GregTechData.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import muramasa.gregtech.cover.*;
import muramasa.gregtech.cover.redstone.CoverRedstoneMachineController;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
Expand All @@ -34,12 +35,20 @@
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.MaterialColor;

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

import static muramasa.gregtech.data.Materials.*;

public class GregTechData {

private static final boolean HC = AntimatterConfig.GAMEPLAY.HARDCORE_CABLES;

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

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

public static void init(Side side) {
if (side == Side.CLIENT)
RecipeMaps.clientMaps();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package muramasa.gregtech.mixin;

import com.mojang.authlib.GameProfile;
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.util.AntimatterPlatformUtils;
import muramasa.gregtech.data.GregTechData;
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(GregTechData.CAPE_LOCATIONS[3]);
if (orString(playerName, "GregoriusT", "OvermindDL1", "jihuayu123", "Yuesha_Kev14", "Evanvenir", "Trinsdar")) info.setReturnValue(GregTechData.CAPE_LOCATIONS[3]);
if (playerName.equals("CrazyJ1984")) info.setReturnValue(GregTechData.CAPE_LOCATIONS[5]);
if (playerName.equals("Mr_Brain")) info.setReturnValue(GregTechData.CAPE_LOCATIONS[2]);
if (playerName.equals("Friedi4321")) info.setReturnValue(GregTechData.CAPE_LOCATIONS[0]);
if (GregTechData.SupporterListGold.contains(playerName)) info.setReturnValue(GregTechData.CAPE_LOCATIONS[4]);
if (GregTechData.SupporterListSilver.contains(playerName)) info.setReturnValue(GregTechData.CAPE_LOCATIONS[1]);
}

private boolean orString(String compare, String... strings){
List<String> list = List.of(strings);
return list.contains(compare);
}
}
59 changes: 59 additions & 0 deletions common/src/main/java/muramasa/gregtech/proxy/CommonHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package muramasa.gregtech.proxy;

import muramasa.gregtech.GregTech;
import net.minecraft.core.NonNullList;

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

import static muramasa.gregtech.data.GregTechData.SupporterListGold;
import static muramasa.gregtech.data.GregTechData.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(GregTech.class.getResourceAsStream("/supporterlist.txt"));
while (tScanner.hasNextLine()) SupporterListSilver.add(tScanner.nextLine().toLowerCase());
tScanner.close();
GregTech.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(GregTech.class.getResourceAsStream("/supporterlistgold.txt"));
while (tScanner.hasNextLine()) SupporterListGold.add(tScanner.nextLine().toLowerCase());
tScanner.close();
GregTech.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")) {
GregTech.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) {
GregTech.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.
39 changes: 39 additions & 0 deletions common/src/main/resources/forge/GT4ReimaginedForge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package trinsdar.gt4r.forge;

import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import trinsdar.gt4r.GT4RConfig;
import trinsdar.gt4r.GT4Reimagined;
import trinsdar.gt4r.Ref;
import trinsdar.gt4r.proxy.ClientHandler;
import trinsdar.gt4r.proxy.CommonHandler;
import trinsdar.gt4r.proxy.ServerHandler;

@Mod(Ref.ID)
public class GT4ReimaginedForge {
public GT4ReimaginedForge(){
new GT4Reimagined();
GT4Reimagined.PROXY = DistExecutor.runForDist(() -> ClientHandler::new, () -> ServerHandler::new); // todo: scheduled to change in new Forge
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverSetup);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, GT4RConfig.COMMON_SPEC);
}

private void clientSetup(final FMLClientSetupEvent e) {
ClientHandler.setup();
}

private void setup(final FMLCommonSetupEvent e) {
CommonHandler.setup();
}

private void serverSetup(final FMLDedicatedServerSetupEvent event){
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package trinsdar.gt4r.forge.mixin;

import net.minecraftforge.common.capabilities.CapabilityDispatcher;
import net.minecraftforge.common.capabilities.CapabilityProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import javax.annotation.Nullable;

@Mixin(CapabilityProvider.class)
public interface GTCapabilityProviderAccessor {

@Accessor(value = "capabilities", remap = false)
@Nullable
CapabilityDispatcher getCapabilitiesGT();
}
9 changes: 9 additions & 0 deletions common/src/main/resources/gregtech.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"required": true,
"package": "muramasa.gregtech.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"AbstractClientPlayerEntityMixin"
],
"minVersion": "0.8"
}
Loading

0 comments on commit b5a1eda

Please sign in to comment.