Skip to content

Commit

Permalink
An NPE bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yuesha-yc committed Jan 18, 2025
1 parent 513afdc commit 8576b8d
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 49 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
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 @@ -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,13 @@ 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 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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.joml.Vector3f;

import com.teammoeg.frostedheart.FHMain;
Expand All @@ -45,6 +47,7 @@
import net.minecraft.core.Vec3i;

public class ScenarioExecutor<T> {
static Marker MARKER = MarkerManager.getMarker("Scenario Executor");
private static class MethodInfo<T> implements ScenarioMethod<T> {
private static class ParamInfo {
String[] paramName;
Expand Down Expand Up @@ -161,7 +164,6 @@ public void execute(T runner, Map<String, String> param) {
public interface ScenarioMethod<T> {
void execute(T scenarioVM, Map<String, String> param);
}
static Logger LOGGER = LogManager.getLogger("ScenarioExecutor");
Class<T> objcls;
public ScenarioExecutor(Class<T> objcls) {
super();
Expand Down Expand Up @@ -295,7 +297,7 @@ public void register(Class<?> clazz) {
registerInst(ctor.newInstance());
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException |
IllegalArgumentException e) {
FHMain.LOGGER.error("Error registering scenario class",e);
FHMain.LOGGER.error(MARKER, "Error registering scenario class",e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Error registering scenario class" + e.getTargetException());
}
Expand All @@ -314,7 +316,7 @@ public void registerInst(Object clazz) {
registerCommand(met.getName(), new MethodInfo<>(Modifier.isStatic(met.getModifiers()) ? null : clazz, met, this));
} catch (ScenarioExecutionException ex) {
ex.printStackTrace();
LOGGER.warn(ex.getMessage());
FHMain.LOGGER.warn(MARKER, ex.getMessage());
}
}
}
Expand All @@ -328,15 +330,14 @@ public void registerStatic(Class<?> clazz) {
} catch (ScenarioExecutionException ex) {

ex.printStackTrace();
LOGGER.warn(ex.getMessage());
FHMain.LOGGER.warn(MARKER, ex.getMessage());
}
}
}
}
static class Test{
public void test(ScenarioConductor sr,@Param("s")String s,@Param("s")Rect r,@Param("")Rect r1) {
System.out.println(s+":"+r+":"+r1);

FHMain.LOGGER.error(s+":"+r+":"+r1);
}
}
public static void main(String[] args) throws SecurityException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public String get(String t,Map<String,String> param) {
if(param.containsKey("call"))
b.append("@Return\n");
//b.append("@EndAct\n");
System.out.println(b.toString());
// System.out.println(b.toString());
return b.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import net.minecraft.nbt.Tag;
import net.minecraft.nbt.ListTag;
import net.minecraftforge.common.util.LazyOptional;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

/**
Expand All @@ -47,6 +48,7 @@
* You should define triggers in script file and activate triggers to make it execute.
* */
public class ScenarioConductor implements NBTSerializable{
Marker MARKER = MarkerManager.getMarker("Scenario Conductor");
//Sence control
private transient Act currentAct;
public Map<ActNamespace,Act> acts=new HashMap<>();
Expand Down Expand Up @@ -203,8 +205,8 @@ public void enterAct(ActNamespace quest) {
data.currentLabel=new ExecuteTarget(old.getScenario().name(),null);
currentAct=data;
copyExecuteInfo(currentAct,old);
System.out.println("new:"+data);
System.out.println("old:"+old);
FHMain.LOGGER.info(MARKER, "Entering new act: "+data);
FHMain.LOGGER.info(MARKER, "Quiting old act: "+old);
old.stop();

}
Expand Down Expand Up @@ -271,7 +273,7 @@ public void save(CompoundTag data, boolean isPacket) {
public void load(CompoundTag data, boolean isPacket) {
getContext().varData.load(data.getCompound("vars"));
getContext().takeSnapshot();
FHMain.LOGGER.info(MarkerManager.getMarker("Scenario Conductor"), data.getCompound("vars"));
FHMain.LOGGER.info(MARKER, data.getCompound("vars"));
ListTag lacts=data.getList("acts", Tag.TAG_COMPOUND);
//Act initact=acts.get(init);
for(Tag v:lacts) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public void tick(Level level) {
} else if (interval == 0) {
clearConnection(level);
// Connect all pipes and endpoints again
System.out.println("full rebuild triggered");
// System.out.println("full rebuild triggered");
if (onConnect != null)
onConnect.run();
interval = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void encode(FriendlyByteBuf buffer) {
public void handle(Supplier<NetworkEvent.Context> context) {
context.get().enqueueWork(() -> {
// on the client side, update HeatNetwork's fields
TemperatureGoogleRenderer.lastHeatNetworkData = data;
TemperatureGoogleRenderer.setHeatNetworkData(data);
});
context.get().setPacketHandled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package com.teammoeg.frostedheart.content.steamenergy;

import com.teammoeg.chorda.block.CEntityBlock;
import com.teammoeg.chorda.block.CPipeBlock;
import com.teammoeg.frostedheart.content.steamenergy.pipe.CPipeBlock;
import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes;
import com.teammoeg.frostedheart.content.steamenergy.capabilities.HeatCapabilities;
import net.minecraft.core.BlockPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.teammoeg.chorda.block.CTickableBlockEntity;
import com.teammoeg.chorda.block.CPipeBlock;
import com.teammoeg.chorda.blockentity.CPipeBlockEntity;
import com.teammoeg.frostedheart.content.steamenergy.pipe.CPipeBlock;
import com.teammoeg.frostedheart.content.steamenergy.pipe.CPipeBlockEntity;
import com.teammoeg.frostedheart.bootstrap.common.FHBlockEntityTypes;
import com.teammoeg.frostedheart.content.climate.render.TemperatureGoogleRenderer;
import com.teammoeg.frostedheart.util.client.Lang;
Expand Down Expand Up @@ -83,8 +83,8 @@ public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneak

Lang.tooltip("heat_stats").forGoggles(tooltip);

if (!TemperatureGoogleRenderer.lastHeatNetworkData.invalid()) {
ClientHeatNetworkData data = TemperatureGoogleRenderer.lastHeatNetworkData;
if (TemperatureGoogleRenderer.hasHeatNetworkData()) {
ClientHeatNetworkData data = TemperatureGoogleRenderer.getHeatNetworkData();

Lang.translate("tooltip", "pressure")
.style(GRAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneak

Lang.tooltip("heat_stats").forGoggles(tooltip);

if (!TemperatureGoogleRenderer.lastHeatNetworkData.invalid()) {
ClientHeatNetworkData data = TemperatureGoogleRenderer.lastHeatNetworkData;
if (TemperatureGoogleRenderer.hasHeatNetworkData()) {
ClientHeatNetworkData data = TemperatureGoogleRenderer.getHeatNetworkData();

Lang.translate("tooltip", "pressure.network")
.style(GRAY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
*
*/

package com.teammoeg.chorda.block;
package com.teammoeg.frostedheart.content.steamenergy.pipe;

import java.util.Map;
import javax.annotation.Nullable;

import com.google.common.collect.Maps;
import com.teammoeg.chorda.blockentity.CPipeBlockEntity;
import com.teammoeg.chorda.util.CUtils;

import net.minecraft.Util;
Expand Down Expand Up @@ -253,7 +252,7 @@ public void tick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSour
BlockState updated=updateBlockState(state, null, null, worldIn, pos);
worldIn.setBlock(pos, updated, 2);
worldIn.sendBlockUpdated(pos, state, updated, 2);
System.out.println("update pipe "+pos);
// System.out.println("update pipe "+pos);
checkNewConnection(worldIn,pos,state,updated);
//System.out.println(pos+" requested update "+updated.getValue(PROPERTY_BY_DIRECTION.get(Direction.UP)));
//if(state!=updated) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teammoeg.chorda.blockentity;
package com.teammoeg.frostedheart.content.steamenergy.pipe;

import blusunrize.immersiveengineering.common.blocks.IEBaseBlockEntity;
import net.minecraft.core.BlockPos;
Expand Down
Loading

0 comments on commit 8576b8d

Please sign in to comment.