Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20' into 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuqi154 committed Jan 18, 2025
2 parents 2e8c59d + 75e713e commit ceda042
Show file tree
Hide file tree
Showing 29 changed files with 170 additions and 103 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ dependencies {

// Caupona
compileOnly fg.deobf("curse.maven:caupona-656147:5116975")
implementation fg.deobf("curse.maven:caupona-656147:5116975")
// implementation fg.deobf("curse.maven:caupona-656147:5116975")

// LDLib
compileOnly fg.deobf("com.lowdragmc.ldlib:ldlib-forge-${minecraft_version}:${ldlib_version}") { transitive = false }
Expand Down
3 changes: 0 additions & 3 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@

Fix steam network
Fix inventory drops
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import javax.annotation.Nonnull;

import blusunrize.immersiveengineering.api.IETags;
import com.teammoeg.caupona.CPFluids;
import com.teammoeg.chorda.util.CRegistries;
import com.teammoeg.frostedheart.FHMain;
import com.teammoeg.frostedheart.bootstrap.common.FHItems;
Expand Down Expand Up @@ -70,13 +69,13 @@ protected void buildRecipes(@Nonnull Consumer<FinishedRecipe> out) {
Item it= CRegistries.getItem(item);
if(it==null||it==Items.AIR) {
FHMain.LOGGER.warn("TWR Recipe: " + item + " not exist");
ps.println(item+","+parts[1]);
FHMain.LOGGER.info(item+","+parts[1]);
}else {
FoodProperties f=it.getFoodProperties();
if(f==null)
ps.println(item+","+parts[1]);
FHMain.LOGGER.info("Food Value: " + item+","+parts[1]);
else
ps.println(item+","+f.getNutrition());
FHMain.LOGGER.info("Food Nutrition: " + item+","+f.getNutrition());
}
NutritionRecipeBuilder dvb=new NutritionRecipeBuilder().item(it);
float grain=Float.parseFloat(parts[2])*10f;
Expand All @@ -94,14 +93,14 @@ protected void buildRecipes(@Nonnull Consumer<FinishedRecipe> out) {
e.printStackTrace();
}

CPFluids.getAll().filter(o->!Arrays.stream(ovride).anyMatch(CRegistries.getRegistryName(o).getPath()::equals)).forEach(f-> {

out.accept(new WaterLevelFluidRecipe(new ResourceLocation(FHMain.MODID,"water_level/"+ CRegistries.getRegistryName(f).getPath()+"_thermos"),Ingredient.of(ItemTags.create(new ResourceLocation(FHMain.MODID,"thermos"))),f,2,2));
});
CPFluids.getAll().filter(o-> CRegistries.getRegistryName(o).getPath().equals("dilute_soup")).forEach(f-> {

out.accept(new WaterLevelFluidRecipe(new ResourceLocation(FHMain.MODID,"water_level/"+ CRegistries.getRegistryName(f).getPath()+"_thermos"),Ingredient.of(ItemTags.create(new ResourceLocation(FHMain.MODID,"thermos"))),f,3,2));
});
// CPFluids.getAll().filter(o->!Arrays.stream(ovride).anyMatch(CRegistries.getRegistryName(o).getPath()::equals)).forEach(f-> {
//
// out.accept(new WaterLevelFluidRecipe(new ResourceLocation(FHMain.MODID,"water_level/"+ CRegistries.getRegistryName(f).getPath()+"_thermos"),Ingredient.of(ItemTags.create(new ResourceLocation(FHMain.MODID,"thermos"))),f,2,2));
// });
// CPFluids.getAll().filter(o-> CRegistries.getRegistryName(o).getPath().equals("dilute_soup")).forEach(f-> {
//
// out.accept(new WaterLevelFluidRecipe(new ResourceLocation(FHMain.MODID,"water_level/"+ CRegistries.getRegistryName(f).getPath()+"_thermos"),Ingredient.of(ItemTags.create(new ResourceLocation(FHMain.MODID,"thermos"))),f,3,2));
// });


recipeTrade(out);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/teammoeg/chorda/team/CTeamDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class CTeamDataManager {

public static CTeamDataManager INSTANCE;
private final MinecraftServer server;
static final LevelResource dataFolder = new LevelResource("fhdata");
public static final LevelResource dataFolder = new LevelResource("fhdata");
static final LevelResource oldDataFolder = new LevelResource("fhresearch");
private Map<UUID, UUID> dataByFTBId = new HashMap<>();
private Map<UUID, TeamDataHolder> dataByChordaId = new HashMap<>();
Expand Down Expand Up @@ -227,6 +227,7 @@ public void load() {
trd.deserialize(nbt, false);
dataByFTBId.put(ftbid, trd.getId());
dataByChordaId.put(trd.getId(), trd);
Chorda.LOGGER.debug("Data file for team " + trd.getId().toString() + " loaded.");
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
Chorda.LOGGER.error("Unexpected data file " + f.getName() + ", ignoring...");
Expand All @@ -250,10 +251,10 @@ public void save() {
try {
NbtIo.writeCompressed(entry.getValue().serialize(false), f);
files.remove(fn);
Chorda.LOGGER.debug("Data file for team " + entry.getKey().toString() + " saved.");
} catch (IOException e) {

e.printStackTrace();
Chorda.LOGGER.error("Unable to save data file for team " + entry.getKey().toString() + ", ignoring...");
e.printStackTrace();
}
}
for (String todel : files) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/teammoeg/chorda/team/TeamDataHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/
package com.teammoeg.chorda.team;

import com.teammoeg.chorda.ChordaNetwork;
import com.teammoeg.chorda.util.utility.OptionalLazy;
import com.teammoeg.chorda.network.CMessage;
import com.teammoeg.frostedheart.FHNetwork;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/teammoeg/chorda/util/CUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
package com.teammoeg.chorda.util;

import com.google.common.collect.ImmutableList;
import com.teammoeg.chorda.Chorda;
import com.teammoeg.chorda.capability.nbt.CNBTCapability;
import com.teammoeg.chorda.util.client.ClientUtils;
import com.teammoeg.chorda.util.io.NBTSerializable;
import com.teammoeg.frostedheart.FHMain;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -252,7 +254,7 @@ public static <C extends Collection<T>, T> C copyCollection(@Nonnull C collectio
return copyCollection;

} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
System.err.println("Failed to copy the collection due to an error: " + e.getMessage());
Chorda.LOGGER.error("Failed to copy the collection due to an error: " + e.getMessage());
e.printStackTrace();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,19 @@ public class TemperatureGoogleRenderer {
public static int hoverTicks = 0;
public static BlockPos lastHovered = null;
public static BlockPos lastHeatNetworkPos = null;
public static ClientHeatNetworkData lastHeatNetworkData = null;
private static ClientHeatNetworkData lastHeatNetworkData = null;

public static boolean hasHeatNetworkData() {
return lastHeatNetworkData != null && !lastHeatNetworkData.invalid();
}

public static ClientHeatNetworkData getHeatNetworkData() {
return lastHeatNetworkData;
}

public static void setHeatNetworkData(ClientHeatNetworkData data) {
lastHeatNetworkData = data;
}

public static void renderOverlay(ForgeGui gui, GuiGraphics graphics, float partialTicks, int width,
int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@
* Main Research System.
*/
public class FHResearch {
/**
* Registry holder for all defined Research in config.
*/
public static FHRegistry<Research> researches = new FHRegistry<>();
/*public static FHRegistry<Clue> clues = new FHRegistry<>();
public static FHRegistry<Effect> effects = new FHRegistry<>();*/
/**
* Cache for all Researches.
*/
private static OptionalLazy<List<Research>> allResearches = OptionalLazy.of(() -> researches.all());
/**
* Editing mode.
*/
public static boolean editor = false;

public static void clearAll() {
Expand All @@ -82,6 +89,10 @@ public static void clearCache() {
allResearches = OptionalLazy.of(() -> researches.all());
}

/**
* Delete a Research from config JSON
* @param r Research to delete
*/
public static void delete(Research r) {
researches.remove(r);
clearCache();
Expand Down Expand Up @@ -176,6 +187,9 @@ else if (r.isShowable())
return available;
}

/**
* Initialization steps after Research data is loaded.
*/
public static void init() {
ClientResearchData.last = null;
ResearchListeners.reload();
Expand Down Expand Up @@ -238,6 +252,11 @@ public static void load(CompoundTag cnbt) {
//effects.deserialize(cnbt.getList("effects", Tag.TAG_STRING));
}

/**
* Load Research from config JSON
* @param r Research to load
* @return Loaded Research
*/
public static Research load(Research r) {
File folder = FMLPaths.CONFIGDIR.get().toFile();
File rf = new File(folder, "fhresearches");
Expand All @@ -264,6 +283,9 @@ public static Research load(Research r) {
return researches.getById(iid);
}

/**
* Load all Research from config JSON
*/
public static void loadAll() {
File folder = FMLPaths.CONFIGDIR.get().toFile();
File rf = new File(folder, "fhresearches");
Expand Down Expand Up @@ -316,7 +338,7 @@ public static void main(String[] args) {
}
// System.out.println(CodecUtil.INGREDIENT_CODEC.encodeStart(DataOps.COMPRESSED, Ingredient.of(Items.ACACIA_BOAT)));
FriendlyByteBuf pb=new FriendlyByteBuf(Unpooled.buffer());
Object prein=Research.CODEC.encodeStart(DataOps.COMPRESSED, new Research()).resultOrPartial(System.out::println).get();
Object prein=Research.CODEC.encodeStart(DataOps.COMPRESSED, new Research()).resultOrPartial(FHMain.LOGGER::debug).get();
// System.out.println(prein);
ObjectWriter.writeObject(pb,prein);
// System.out.println();
Expand Down Expand Up @@ -415,37 +437,44 @@ public static void sendSyncPacket(PacketTarget target) {
FHNetwork.send(target, new FHResearchSyncEndPacket());
}

private static final LevelResource dataFolder = new LevelResource("fhdata");

/**
* Load Research data from disk.
*/
public static void load() {
FHResearch.editor = false;
Path local = CTeamDataManager.getServer().getWorldPath(dataFolder);
Path local = CTeamDataManager.getServer().getWorldPath(CTeamDataManager.dataFolder);
File regfile = new File(local.toFile().getParentFile(), "fhregistries.dat");
FHResearch.clearAll();
if (regfile.exists()) {
try {
FHResearch.load(NbtIo.readCompressed(regfile));
FHMain.LOGGER.info("Research registries loaded.");
} catch (IOException e) {
e.printStackTrace();
FHMain.LOGGER.fatal("CANNOT READ RESEARCH REGISTRIES, MAY CAUSE UNSYNC!");

}
} else
FHMain.LOGGER.error("NO REGISTRY FOUND");
} else {
FHMain.LOGGER.error("No registry file found when loading research data.");
}
FHResearch.init();
FHMain.LOGGER.info("RESEARCH DATA INITIALIZED");
local.toFile().mkdirs();
try {
File dbg = new File(local.toFile().getParentFile(), "fheditor.dat");
if (dbg.exists() && FileUtil.readString(dbg).equals("true"))
FHResearch.editor = true;
} catch (IOException e2) {
// TODO Auto-generated catch block
FHMain.LOGGER.error("Cannot read editor status");
e2.printStackTrace();
}
}

/**
* Save Research data to disk.
*/
public static void save() {
Path local = CTeamDataManager.getServer().getWorldPath(dataFolder);
Path local = CTeamDataManager.getServer().getWorldPath(CTeamDataManager.dataFolder);
File regfile = new File(local.toFile().getParentFile(), "fhregistries.dat");
File dbg = new File(local.toFile().getParentFile(), "fheditor.dat");
try {
Expand All @@ -454,11 +483,12 @@ public static void save() {
else if (dbg.exists())
FileUtil.transfer("false", dbg);
} catch (IOException e2) {
// TODO Auto-generated catch block
FHMain.LOGGER.error("Cannot save editor status");
e2.printStackTrace();
}
try {
NbtIo.writeCompressed(FHResearch.save(new CompoundTag()), regfile);
FHMain.LOGGER.info("Research Registries saved.");
} catch (IOException e1) {
e1.printStackTrace();
FHMain.LOGGER.fatal("CANNOT SAVE RESEARCH REGISTRIES, MAY CAUSE UNSYNC!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public ResearchDataPacket write(Research r) {
clueData.add(this.clueData.get(c.getNonce()));
int i=0;
for(Effect e:r.getEffects()) {
effectData.set(i++,this.effectData.get(e.getNonce()));
effectData.set(i++,this.effectData.getOrDefault(e.getNonce(), false));
}
return new ResearchDataPacket(active,finished,level,committed,clueData,effectData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.function.Supplier;

import com.mojang.logging.LogUtils;
import com.teammoeg.chorda.network.CMessage;
import com.teammoeg.frostedheart.content.research.FHResearch;
import com.teammoeg.frostedheart.content.research.research.Research;
Expand All @@ -44,13 +45,16 @@ public FHResearchSyncPacket(FriendlyByteBuf buffer) {

public void encode(FriendlyByteBuf buffer) {
ObjectWriter.writeObject(buffer, data);
System.out.println("encoded "+key+":"+data);
// LogUtils.getLogger().debug("Encoded research "+key+":"+data);
buffer.writeUtf(key);
}

public void handle(Supplier<NetworkEvent.Context> context) {

context.get().enqueueWork(() -> {System.out.println("decoded "+key+":"+data);FHResearch.readOne(key,CodecUtil.decodeOrThrow(Research.CODEC.decode(DataOps.COMPRESSED, data)));});
context.get().enqueueWork(() -> {
// LogUtils.getLogger().debug("Decoded research "+key+":"+data);
FHResearch.readOne(key,CodecUtil.decodeOrThrow(Research.CODEC.decode(DataOps.COMPRESSED, data)));
});
context.get().setPacketHandled(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public BaseData(String name, List<String> tooltip, Optional<FHIcon> icon, String
}

}
public static final MapCodec<BaseData> BASE_CODEC=CodecUtil.debugCodec(RecordCodecBuilder.mapCodec(t->
public static final MapCodec<BaseData> BASE_CODEC=RecordCodecBuilder.mapCodec(t->
t.group(
Codec.STRING.optionalFieldOf("name","").forGetter(o->o.name),
Codec.list(Codec.STRING).optionalFieldOf("tooltip",Arrays.asList()).forGetter(o->o.tooltip),
FHIcons.CODEC.optionalFieldOf("icon").forGetter(o->Optional.ofNullable(o.icon)),
Codec.STRING.fieldOf("id").forGetter(o->o.nonce),
Codec.BOOL.optionalFieldOf("hidden",false).forGetter(o->o.hidden)).apply(t, BaseData::new)));
Codec.BOOL.optionalFieldOf("hidden",false).forGetter(o->o.hidden)).apply(t, BaseData::new));
private static TypedCodecRegistry<Effect> registry = new TypedCodecRegistry<>();
public static final Codec<Effect> CODEC=registry.codec();
static {
Expand All @@ -85,7 +85,7 @@ public BaseData(String name, List<String> tooltip, Optional<FHIcon> icon, String
registerEffectType(EffectExperience.class, "experience", EffectExperience.CODEC);
}
public static <T extends Effect> void registerEffectType(Class<T> cls, String type, MapCodec<T> json) {
registry.register(cls, type, CodecUtil.debugCodec(json));
registry.register(cls, type, json);
}

String name = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.stream.Collectors;

import com.mojang.datafixers.util.Either;
import com.mojang.logging.LogUtils;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
Expand Down Expand Up @@ -172,8 +173,10 @@ private void initItem() {
unlocks.clear();
for (Recipe<?> r : CTeamDataManager.getRecipeManager().getRecipes()) {
ItemStack result=r.getResultItem(CRegistries.getAccess());
if(result==null)System.out.println("error null recipe "+r);
if (result!=null&&ingredient.test(result)) {
if(result==null) {
LogUtils.getLogger().debug("Error null recipe "+r);
}
if (ingredient.test(result)) {
unlocks.add(r);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.util.NoSuchElementException;
import java.util.Objects;

import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.objectweb.asm.Type;

import com.teammoeg.frostedheart.FHMain;
Expand Down Expand Up @@ -63,13 +65,14 @@
import net.minecraftforge.network.PacketDistributor;

public class FHScenario {
static Marker MARKER = MarkerManager.getMarker("Scenario Conductor");
public static ScenarioExecutor<ScenarioCommandContext> server = new ScenarioExecutor<>(ScenarioCommandContext.class);
private static final List<ScenarioProvider> scenarioProviders = new ArrayList<>();
public static Map<Player,Map<EventTriggerType,List<IVarTrigger>>> triggers=new HashMap<>();
//private static Map<ServerPlayerEntity,ScenarioConductor> runners=new HashMap<>();
public static void startFor(ServerPlayer pe,String lang) {
ScenarioConductor sr = get(pe);
System.out.println("From saved: "+pe.getLanguage()+" From packet: "+lang);
FHMain.LOGGER.debug(MARKER, "From saved: "+pe.getLanguage()+" From packet: "+lang);
sr.init(pe,lang);


Expand Down
Loading

0 comments on commit ceda042

Please sign in to comment.