Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/7.1' into 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Feb 25, 2024
2 parents 3308885 + 06bc99e commit 91d5abc
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 96 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bta_version=7.1-pre1a
loader_version=0.14.19-babric.3-bta

# Mod
mod_version=3.4.8
mod_version=3.4.9
mod_group=turniplabs
mod_name=halplibe

12 changes: 1 addition & 11 deletions src/main/java/turniplabs/halplibe/HalpLibe.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,26 @@
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import net.minecraft.client.entity.fx.EntityFireflyFX;
import net.minecraft.client.render.block.model.BlockModelRenderBlocks;
import net.minecraft.client.sound.block.BlockSounds;
import net.minecraft.core.Global;
import net.minecraft.core.block.Block;
import net.minecraft.core.block.BlockLanternFirefly;
import net.minecraft.core.block.tag.BlockTags;
import net.minecraft.core.data.gamerule.GameRuleBoolean;
import net.minecraft.core.data.gamerule.GameRules;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemPlaceable;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.item.tag.ItemTags;
import net.minecraft.core.util.helper.MathHelper;
import net.minecraft.core.world.biome.Biome;
import net.minecraft.core.world.biome.Biomes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.*;
import turniplabs.halplibe.mixin.accessors.EntityFireflyFXAccessor;
import turniplabs.halplibe.util.FireflyColor;
import turniplabs.halplibe.util.GameStartEntrypoint;
import turniplabs.halplibe.util.TomlConfigHandler;
import turniplabs.halplibe.util.achievements.AchievementPage;
import turniplabs.halplibe.util.achievements.VanillaAchievementsPage;
import turniplabs.halplibe.util.toml.Toml;
import turniplabs.halplibe.util.version.PacketModList;

import java.util.HashMap;
import java.util.Random;

public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {
public static final String MOD_ID = "halplibe";
Expand Down Expand Up @@ -113,7 +103,7 @@ public void onInitialize() {
public static FireflyColor fireflyBlue;
public static FireflyColor fireflyRed;

public static GameRuleBoolean UNLOCK_ALL_RECIPES = (GameRuleBoolean) GameRules.register(new GameRuleBoolean("unlockAllRecipes", false));
public static GameRuleBoolean UNLOCK_ALL_RECIPES = GameRules.register(new GameRuleBoolean("unlockAllRecipes", false));

@Override
public void onPreLaunch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.ArrayList;
import java.util.List;

public class AchievementHelper {
abstract public class AchievementHelper {
private static final List<AchievementPage> pages = new ArrayList<>();

public static List<AchievementPage> getPages() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/ArmorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.core.util.helper.DamageType;
import turniplabs.halplibe.util.ArmorMaterialMixinInterface;

public class ArmorHelper {
abstract public class ArmorHelper {

/**
* Damage parameters can be more than 100%. Armor durability will be a bit different from in-game.
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/turniplabs/halplibe/helper/BlockBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
import org.apache.commons.lang3.StringUtils;
import turniplabs.halplibe.mixin.accessors.BlockFireAccessor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.*;
import java.util.stream.Collectors;

public class BlockBuilder implements Cloneable {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/BlockHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.function.Consumer;

public class BlockHelper {
abstract public class BlockHelper {

public static int highestVanilla;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;

public class CommandHelper {
abstract public class CommandHelper {
@ApiStatus.Internal // used in CommandsCoreMixin
private static final List<Command> coreCommands = new ArrayList<>();
@ApiStatus.Internal // used in CommandsClientMixin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.core.item.ItemStack;
import turniplabs.halplibe.util.CreativeEntry;

public class CreativeHelper {
abstract public class CreativeHelper {
/**
* @param itemToAdd The itemstack to be added to the creative inventory list
* @param priority the priority for the item to be added, lower numbers appear higher in the list. Default is 1000
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/EntityHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.Map;

public class EntityHelper {
abstract public class EntityHelper {
/**
* @deprecated No longer works serverside as of BTA 7.1 due to the removal of "Minecraft.class" from the server jar
* Replaced by {@link Core#createEntity(Class, int, String)} and {@link Client#assignEntityRenderer(Class, EntityRenderer)}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/turniplabs/halplibe/helper/FireflyHelper.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package turniplabs.halplibe.helper;

import net.minecraft.client.entity.fx.EntityFireflyFX;
import net.minecraft.core.block.BlockLanternFirefly;
import turniplabs.halplibe.mixin.accessors.EntityFireflyFXAccessor;
import turniplabs.halplibe.util.FireflyColor;
import turniplabs.halplibe.util.IFireflyColor;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/ItemHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class ItemHelper {
abstract public class ItemHelper {

public static int highestVanilla;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.ArrayList;
import java.util.List;

public class ModVersionHelper {
abstract public class ModVersionHelper {
protected static boolean isDev = FabricLoader.getInstance().isDevelopmentEnvironment();
protected static List<ModInfo> localMods = new ArrayList<>();
protected static List<ModInfo> serverMods = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.TreeSet;
import java.util.function.Consumer;

public class NetworkHelper {
abstract public class NetworkHelper {
private static final TreeSet<NetworkEntry> ENTRIES = new TreeSet<>();
private static boolean locked = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.HashMap;
import java.util.Map;

public class ParticleHelper {
abstract public class ParticleHelper {
public static Map<String, Class<? extends EntityFX>> particlesOld = new HashMap<>();
public static Map<String, ParticleLambda> particles = new HashMap<>();

Expand Down
24 changes: 4 additions & 20 deletions src/main/java/turniplabs/halplibe/helper/RecipeBuilder.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
package turniplabs.halplibe.helper;

import com.b100.utils.FileUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.TypeAdapter;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import net.minecraft.core.Global;
import net.minecraft.core.WeightedRandomBag;
import net.minecraft.core.WeightedRandomLootObject;
import net.minecraft.core.data.registry.Registries;
import net.minecraft.core.data.registry.recipe.HasJsonAdapter;
import net.minecraft.core.data.registry.recipe.RecipeEntryBase;
import net.minecraft.core.data.registry.recipe.RecipeGroup;
import net.minecraft.core.data.registry.recipe.RecipeNamespace;
import net.minecraft.core.data.registry.recipe.RecipeSymbol;
import net.minecraft.core.data.registry.recipe.adapter.ItemStackJsonAdapter;
import net.minecraft.core.data.registry.recipe.adapter.RecipeJsonAdapter;
import net.minecraft.core.data.registry.recipe.adapter.RecipeSymbolJsonAdapter;
import net.minecraft.core.data.registry.recipe.adapter.WeightedRandomBagJsonAdapter;
import net.minecraft.core.data.registry.recipe.adapter.WeightedRandomLootObjectJsonAdapter;
import net.minecraft.core.data.registry.recipe.*;
import net.minecraft.core.data.registry.recipe.adapter.*;
import net.minecraft.core.item.ItemStack;
import turniplabs.halplibe.helper.recipeBuilders.RecipeBuilderBlastFurnace;
import turniplabs.halplibe.helper.recipeBuilders.RecipeBuilderFurnace;
import turniplabs.halplibe.helper.recipeBuilders.RecipeBuilderShaped;
import turniplabs.halplibe.helper.recipeBuilders.RecipeBuilderShapeless;
import turniplabs.halplibe.helper.recipeBuilders.RecipeBuilderTrommel;
import turniplabs.halplibe.helper.recipeBuilders.*;
import turniplabs.halplibe.helper.recipeBuilders.modifiers.BlastFurnaceModifier;
import turniplabs.halplibe.helper.recipeBuilders.modifiers.FurnaceModifier;
import turniplabs.halplibe.helper.recipeBuilders.modifiers.TrommelModifier;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/RecipeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Replace by the RecipeBuilder
*/
@Deprecated
public class RecipeHelper {
abstract public class RecipeHelper {
@Deprecated
public static final CraftingManager craftingManager = CraftingManager.getInstance();
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.ArrayList;
import java.util.function.Consumer;

public class RegistryHelper {
abstract public class RegistryHelper {
private static final ArrayList<Runnable> registryFunctions = new ArrayList<>();
private static final ArrayList<Runnable> configuredRegistryFunctions = new ArrayList<>();
private static final ArrayList<Runnable> smartRegistryFunctions = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/SoundHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Hashtable;


public class SoundHelper {
abstract public class SoundHelper {
private static final Hashtable<String, String> fileCache = new Hashtable<>();
public static final File appDirectory;
public static final File soundDirectory;
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/turniplabs/halplibe/helper/TextureHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

import net.minecraft.core.Global;
import net.minecraft.core.block.Block;
import turniplabs.halplibe.util.BlockCoords;
import turniplabs.halplibe.util.DirectoryManager;
import turniplabs.halplibe.util.ItemCoords;
import turniplabs.halplibe.util.ParticleCoords;
import turniplabs.halplibe.util.TextureHandler;
import turniplabs.halplibe.util.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TextureHelper {
abstract public class TextureHelper {
public static List<String> supportedImageFormats = new ArrayList<>();
static {
supportedImageFormats.add("BMP");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import turniplabs.halplibe.util.FireflyColor;
import turniplabs.halplibe.util.IFireflyColor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Debug(export = true)
@Mixin(value = EntityFireflyCluster.class, remap = false)
Expand All @@ -39,30 +42,8 @@ public EntityFireflyClusterMixin(World world) {
public void spawnInit() {
super.init();
Biome currentBiome = this.world.getBlockBiome((int)this.x, (int)this.y, (int)this.z);
FireflyColor finalColor = null;
List<FireflyColor> colors = FireflyHelper.registeredColors;

for (FireflyColor color : colors) {
Biome[] spawnBiomes = color.getSpawnBiomes();
if (spawnBiomes != null) {
for (Biome spawnBiome : spawnBiomes) {
if (spawnBiome == currentBiome) {
finalColor = color;
break;
}
}

if (finalColor != null) {
break;
}
}
}

if (finalColor == null) {
finalColor = HalpLibe.fireflyGreen;
}

halplibe$setColor(finalColor);
FireflyColor color = halplibe$getColourForBiome(currentBiome);
halplibe$setColor(color);
}

@Inject(
Expand Down Expand Up @@ -126,19 +107,28 @@ public void spawnInit() {
@Unique
private FireflyColor halplibe$getColourForBiome(Biome currentBiome) {
List<FireflyColor> colors = FireflyHelper.registeredColors;
List<FireflyColor> colorsWithThisBiome = new ArrayList<>();

float totalWeight = 0f;
for (FireflyColor color : colors) {
Biome[] spawnBiomes = color.getSpawnBiomes();

if (spawnBiomes != null) {
for (Biome biome : spawnBiomes) {
if (biome == currentBiome) {
return color;
}
}
Float weight = color.getBiomeAndWeights().get(currentBiome);
if (weight != null) {
totalWeight += weight;
colorsWithThisBiome.add(color);
}
}

return HalpLibe.fireflyGreen;
int index = 0;
float r = (float) Math.random() * totalWeight;
for (; index < colorsWithThisBiome.size() - 1; index++) {
r -= colorsWithThisBiome.get(index).getBiomeAndWeights().get(currentBiome);
if (r <= 0.0) break;
}

if (totalWeight == 0f) {
return HalpLibe.fireflyGreen;
} else {
return colorsWithThisBiome.get(index);
}
}
}
Loading

0 comments on commit 91d5abc

Please sign in to comment.