Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.launchwrapper.Launch;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
Expand All @@ -16,6 +15,7 @@
import pl.pabilo8.immersiveintelligence.api.data.radio.RadioNetwork;
import pl.pabilo8.immersiveintelligence.common.CommonProxy;
import pl.pabilo8.immersiveintelligence.common.IIConfigHandler;
import pl.pabilo8.immersiveintelligence.common.IIConfigHandler.IIConfig.Factions;
import pl.pabilo8.immersiveintelligence.common.IILogger;
import pl.pabilo8.immersiveintelligence.common.IISaveData;
import pl.pabilo8.immersiveintelligence.common.commands.CommandII;
Expand All @@ -24,11 +24,10 @@
import pl.pabilo8.immersiveintelligence.common.event.LightEngineerEventHandler;
import pl.pabilo8.immersiveintelligence.common.util.IIReflectionUtils;
import pl.pabilo8.immersiveintelligence.common.util.IISkinHandler;
import pl.pabilo8.immersiveintelligence.common.util.diplomacy.DiplomacyUtils;
import pl.pabilo8.immersiveintelligence.common.util.diplomacy.DiplomacyHandler;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static pl.pabilo8.immersiveintelligence.ImmersiveIntelligence.MODID;
import static pl.pabilo8.immersiveintelligence.ImmersiveIntelligence.VERSION;
Expand All @@ -42,7 +41,8 @@ public class ImmersiveIntelligence
public static final String MODID = "immersiveintelligence";
public static final String VERSION = "@VERSION@";
//If anyone wants to acquire a righteously certified loicense:tm:, ask @Pabilo8, it is probable he can grant you one
private static final HashMap<String, String> alternativeCerts = new HashMap<String,String>(){{
private static final HashMap<String, String> alternativeCerts = new HashMap<String, String>()
{{
put("gabriel@iiteam.net", "73cf50303bda0cde99468a637a9d2681a4d7a125");
put("pabilo@iiteam.net", "48791e3791eac0c69a01301060895dc0f4f15f68");
put("avalon@iiteam.net", "172df79c3bca2e9546b739451f4e32acf4872aae");
Expand Down Expand Up @@ -75,7 +75,6 @@ public void preInit(FMLPreInitializationEvent event)
IIConfigHandler.putConfigValues();
//Pre-Init
proxy.preInit(event);
ForgeChunkManager.setForcedChunkLoadingCallback(this, proxy);
//Start contributor skins json download thread
new IISkinHandler.ThreadContributorSpecialsDownloader();
}
Expand Down Expand Up @@ -105,11 +104,20 @@ public void loadComplete(FMLLoadCompleteEvent event)
}

@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event)
public void serverAboutToStart(FMLServerAboutToStartEvent event)
{
IILogger.debug("Pre-World Load cleanup");
CommonProxy.refreshFluidReferences();
RadioNetwork.INSTANCE.clearDevices();
if(Factions.enableFactions)
DiplomacyHandler.getInstance(false).init();
}

@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event)
{
IILogger.debug("Registering II Commands");
event.registerServerCommand(new CommandII());

if(FMLCommonHandler.instance().getEffectiveSide()==Side.SERVER)
{
Expand All @@ -125,26 +133,25 @@ public void serverStarting(FMLServerStartingEvent event)
}
else
IILogger.info("WorldData retrieved");
IISaveData.setInstance(world.provider.getDimension(), worldData);
IISaveData.setInstance(worldData);
}
IILogger.debug("Registering II Commands");
event.registerServerCommand(new CommandII());
}

@EventHandler
public void onFMLServerStopped(FMLServerStoppedEvent event)
{
IILogger.info("Post-World Unload cleanup");
DiplomacyUtils.unload();
RadioNetwork.INSTANCE.clearDevices();
if(Factions.enableFactions)
DiplomacyHandler.getInstance(false).cleanup();
}


@Mod.EventHandler
public void wrongSignature(FMLFingerprintViolationEvent event)
{
boolean loicense = false;
for(Map.Entry<String,String> altCert : alternativeCerts.entrySet())
for(Map.Entry<String, String> altCert : alternativeCerts.entrySet())
if(event.getFingerprints().contains(altCert.getValue()))
{
System.out.println("[Immersive Intelligence/Error] "+altCert.getKey()+" ("+altCert.getValue()+") is considered a righteously loicensed certificate. "+
Expand Down
33 changes: 19 additions & 14 deletions src/main/java/pl/pabilo8/immersiveintelligence/api/LogisticTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import pl.pabilo8.immersiveintelligence.common.util.IIColor;
import pl.pabilo8.immersiveintelligence.common.util.IIReference;
import pl.pabilo8.immersiveintelligence.common.util.IIStringUtil;
import pl.pabilo8.immersiveintelligence.common.util.diplomacy.DiplomacyUtils;
import pl.pabilo8.immersiveintelligence.common.util.diplomacy.DiplomacyHandler;
import pl.pabilo8.immersiveintelligence.common.util.diplomacy.OwnerIdentity;
import pl.pabilo8.immersiveintelligence.common.util.easynbt.EasyNBT;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

/**
* Represents a transportable item tag used by the II logistics system.
Expand All @@ -43,7 +44,7 @@ public class LogisticTag implements INBTSerializable<NBTTagCompound>, Cloneable
//--- Properties ---//
private String name = "";
private String description = "";
private OwnerIdentity owner = DiplomacyUtils.NEUTRAL;
private UUID owner = null;
private String origin = "";
private String destination = "";
private EnumDyeColor color = null;
Expand Down Expand Up @@ -96,9 +97,12 @@ else if(packet.has('s'))
IIDataHandlingUtils.optionalString('t', packet)
.ifPresent(string -> this.destination = string);
//Owner
IIDataHandlingUtils.optionalString('o', packet)
.map(DiplomacyUtils::getIdentityByName)
.ifPresent(identity -> this.owner = identity);
try
{
IIDataHandlingUtils.optionalString('o', packet)
.map(UUID::fromString)
.ifPresent(uuid -> this.owner = uuid);
} catch(IllegalArgumentException ignored) {}
//Color (Paint)
IIDataHandlingUtils.optionalColor('p', packet)
.ifPresent(color -> this.color = color.getDyeColor());
Expand Down Expand Up @@ -131,7 +135,7 @@ public LogisticTag withDescription(String description)

public LogisticTag withOwner(@Nonnull OwnerIdentity owner)
{
this.owner = owner;
this.owner = owner.getUUID();
return this;
}

Expand Down Expand Up @@ -171,9 +175,9 @@ public String getDescription()
return description;
}

public OwnerIdentity getOwner()
public OwnerIdentity getOwner(boolean isRemote)
{
return owner;
return DiplomacyHandler.getInstance(isRemote).getIdentityByUUID(owner);
}

public String getOrigin()
Expand Down Expand Up @@ -207,7 +211,7 @@ public NBTTagCompound serializeNBT()
.withString("origin", origin)
.withString("destination", destination)
.withColor("color", IIColor.fromDye(color))
.withString("owner", (owner==null?DiplomacyUtils.NEUTRAL: owner).getDisplayName())
.withUUID("owner", owner)
.withInt("batch_number", batchNumber)
.unwrap();
}
Expand All @@ -225,8 +229,8 @@ public void deserializeNBT(NBTTagCompound nbt)
color = null;
enbt.checkSetColor("color", found -> color = found.getDyeColor());
//Owner
owner = DiplomacyUtils.NEUTRAL;
enbt.checkSetString("owner", DiplomacyUtils::getIdentityByName);
owner = null;
enbt.checkSetUUID("owner", uuid -> owner = uuid);
}

//--- Utils ---//
Expand Down Expand Up @@ -271,8 +275,9 @@ public List<String> addLogisticsTooltip(List<String> tooltip)
tooltip.add(I18n.format(TRANSLATION_KEY+"batch_number", TextFormatting.WHITE+""+batchNumber));

//Owner
if(owner!=DiplomacyUtils.NEUTRAL)
tooltip.add(I18n.format(TRANSLATION_KEY+"owner", TextFormatting.WHITE+owner.getDisplayName()));
if(owner!=null&&owner!=DiplomacyHandler.NEUTRAL_UUID)
tooltip.add(I18n.format(TRANSLATION_KEY+"owner", TextFormatting.WHITE+
DiplomacyHandler.getInstance(true).getIdentityByUUID(owner).getDisplayName()));
//To and From
if(!origin.isEmpty())
tooltip.add(I18n.format(TRANSLATION_KEY+"origin", TextFormatting.WHITE+origin));
Expand Down Expand Up @@ -361,7 +366,7 @@ public String toString()
return "LogisticsTag{"+
"name='"+name+'\''+
", description='"+description+'\''+
(owner==DiplomacyUtils.NEUTRAL?"": ", owner="+owner)+
(owner!=null&&owner!=DiplomacyHandler.NEUTRAL_UUID?"": ", owner="+owner)+
", origin='"+origin+'\''+
", destination='"+destination+'\''+
(color==null?"": ", color="+color)+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public static DryingInformation getDryingInformationFor(ItemStack outputStack)
if(information.outputPredicate.matchesItemStackIgnoringSize(outputStack))
return information;

IILogger.error("Could not find drying information for stack "+outputStack);
if(!outputStack.isEmpty())
IILogger.error("Could not find drying information for stack "+outputStack);
return new DryingInformation(new IngredientStack(ItemStack.EMPTY),
new FluidStack(FluidRegistry.WATER, 1000), Coagulator.bucketTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public int getTorque()
@Override
public int getMinSpeed()
{
return Sawmill.rpmMin;
return Sawmill.speedMin;
}

@Override
public int getMaxSpeed()
{
return Sawmill.rpmBreakingMax;
return Sawmill.speedBreaking;
}

public int getHardness()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,34 @@
import blusunrize.immersiveengineering.api.ComparableItemStack;
import blusunrize.immersiveengineering.api.crafting.IngredientStack;
import blusunrize.immersiveengineering.common.util.ListUtils;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.oredict.OreDictionary;
import pl.pabilo8.immersiveintelligence.ImmersiveIntelligence;
import pl.pabilo8.immersiveintelligence.api.crafting.recipe.IIMultiblockRecipe;
import pl.pabilo8.immersiveintelligence.api.crafting.recipe.IIRecipeLayout;
import pl.pabilo8.immersiveintelligence.api.crafting.recipe.IIRecipeLayout.IOType;
import pl.pabilo8.immersiveintelligence.api.crafting.recipe.IIRecipeLayoutBuilder;

import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Function;

/**
* Vulcanizer production recipe.
*
* @author Pabilo8 (pabilo@iiteam.net)
* @updated 10.05.2026
* @ii-approved 0.3.1
* @since 20.06.2021
*/
//REFACTOR: 06.12.2025 move to new system fully
public class VulcanizerRecipe extends IIMultiblockRecipe
{
public static final ResourceLocation TEXTURE_LATEX = new ResourceLocation(ImmersiveIntelligence.MODID, "textures/blocks/multiblock/vulcanizer/latex_strip.png");
public static final ResourceLocation TEXTURE_RUBBER = new ResourceLocation(ImmersiveIntelligence.MODID, "textures/blocks/multiblock/vulcanizer/rubber_strip.png");
public static ArrayListMultimap<ComparableItemStack, VulcanizerRecipe> recipeList = ArrayListMultimap.create();
public static HashMap<String, Function<NBTTagCompound, VulcanizerRecipe>> deserializers = new HashMap<>();
public final IngredientStack input;
public final IngredientStack compoundInput;
public final IngredientStack sulfurInput;

public final IngredientStack input, compoundInput, sulfurInput;
public final ResourceLocation resIn, resOut;
public final ComparableItemStack mold;
public final ItemStack output;
public final ResourceLocation resIn, resOut;

public VulcanizerRecipe(ItemStack output, ComparableItemStack mold, IngredientStack mainInput, IngredientStack compoundInput, IngredientStack sulfurInput, int energy, ResourceLocation resIn, ResourceLocation resOut)
{
Expand All @@ -57,84 +50,18 @@ public VulcanizerRecipe(ItemStack output, ComparableItemStack mold, IngredientSt
this.resOut = resOut;
}

public static VulcanizerRecipe addRecipe(ItemStack output, ComparableItemStack mold, IngredientStack input, IngredientStack compound, IngredientStack sulfur, int energy)
{
return addRecipe(output, mold, input, compound, sulfur, energy, TEXTURE_LATEX, TEXTURE_RUBBER);
}

public static VulcanizerRecipe addRecipe(ItemStack output, ComparableItemStack mold, IngredientStack input, IngredientStack compound, IngredientStack sulfur, int energy, ResourceLocation resIn, ResourceLocation resOut)
{
VulcanizerRecipe r = new VulcanizerRecipe(output, mold, input, compound, sulfur, energy, resIn, resOut);
recipeList.put(mold, r);
return r;
}

public static VulcanizerRecipe findRecipe(ItemStack mold, ItemStack input)
public VulcanizerRecipe(ItemStack output, ComparableItemStack mold, IngredientStack mainInput, IngredientStack compoundInput, IngredientStack sulfurInput, int energy)
{
if(mold.isEmpty()||input.isEmpty())
return null;
ComparableItemStack comp = ApiUtils.createComparableItemStack(mold, false);
List<VulcanizerRecipe> list = recipeList.get(comp);
for(VulcanizerRecipe recipe : list)
if(recipe.matches(mold, input))
return recipe.getActualRecipe(mold, input);
return null;
}

public static List<VulcanizerRecipe> removeRecipes(ItemStack output)
{
List<VulcanizerRecipe> list = new ArrayList<>();
Set<ComparableItemStack> keySet = new HashSet<>(recipeList.keySet());
for(ComparableItemStack mold : keySet)
{
Iterator<VulcanizerRecipe> it = recipeList.get(mold).iterator();
while(it.hasNext())
{
VulcanizerRecipe ir = it.next();
if(OreDictionary.itemMatches(ir.output, output, true))
{
list.add(ir);
it.remove();
}
}
}
return list;
this(output, mold, mainInput, compoundInput, sulfurInput, energy, TEXTURE_LATEX, TEXTURE_RUBBER);
}

public static boolean isValidMold(ItemStack itemStack)
{
if(itemStack.isEmpty())
return false;
return recipeList.containsKey(ApiUtils.createComparableItemStack(itemStack, false));
}

public static VulcanizerRecipe loadFromNBT(NBTTagCompound nbt)
{
if(nbt.hasKey("type")&&deserializers.containsKey(nbt.getString("type")))
return deserializers.get(nbt.getString("type")).apply(nbt);
IngredientStack input = IngredientStack.readFromNBT(nbt.getCompoundTag("input"));
ComparableItemStack mold = ComparableItemStack.readFromNBT(nbt.getCompoundTag("mold"));
List<VulcanizerRecipe> list = recipeList.get(mold);
for(VulcanizerRecipe recipe : list)
if(recipe.input.equals(input))
return recipe;
return null;
}

public VulcanizerRecipe setInputSize(int size)
{
this.input.inputSize = size;
return this;
}

public boolean matches(ItemStack mold, ItemStack input)
{
return this.input.matches(input);
}

public VulcanizerRecipe getActualRecipe(ItemStack mold, ItemStack input)
{
return this;
ComparableItemStack comparable = new ComparableItemStack(itemStack);
return streamRecipes(VulcanizerRecipe.class)
.anyMatch(recipe -> recipe.mold.equals(comparable));
}

@Nullable
Expand All @@ -152,12 +79,4 @@ protected IIRecipeLayout initRecipeLayout()
.withPowerInfo()
.build();
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
nbt.setTag("mold", mold.writeToNBT(new NBTTagCompound()));
nbt.setTag("input", input.writeToNBT(new NBTTagCompound()));
return nbt;
}
}
Loading
Loading