Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7.1 changes #36

Merged
merged 12 commits into from
Dec 2, 2023
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2G

# BTA
bta_version=1.7.7.0_02
bta_version=1.7.7.1

# Loader
loader_version=0.14.19-babric.1-bta
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/turniplabs/halplibe/HalpLibe.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import net.minecraft.core.Global;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.AchievementHelper;
Expand All @@ -14,6 +16,9 @@
import turniplabs.halplibe.util.toml.Toml;
import turniplabs.halplibe.util.version.PacketModList;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {
public static final String MOD_ID = "halplibe";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
Expand All @@ -25,7 +30,6 @@ public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {

CONFIG = new TomlConfigHandler(MOD_ID, toml);

//Global.TEXTURE_ATLAS_WIDTH_TILES = Math.max(32, CONFIG.getInt("Experimental.AtlasWidth"));
// Initialize Block and Item static fields
try {
Class.forName("net.minecraft.core.block.Block");
Expand All @@ -38,7 +42,6 @@ public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {
public static String addModId(String modId, String name) {
return modId + "." + name;
}

@Override
public void onInitialize() {
AchievementHelper.addPage(VANILLA_ACHIEVEMENTS);
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/turniplabs/halplibe/helper/ArmorHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import net.minecraft.core.item.material.ArmorMaterial;
import net.minecraft.core.util.helper.DamageType;
import org.apache.commons.lang3.ArrayUtils;
import turniplabs.halplibe.mixin.accessors.RenderPlayerAccessor;

public class ArmorHelper {

Expand All @@ -19,16 +17,12 @@ public class ArmorHelper {
* @return the new ArmorMaterial.
*/
public static ArmorMaterial createArmorMaterial(String textureName, int durability, float combat, float blast, float fire, float fall) {
String[] armorFilenamePrefix = RenderPlayerAccessor.getArmorFilenamePrefix();
armorFilenamePrefix = ArrayUtils.add(armorFilenamePrefix, textureName);
RenderPlayerAccessor.setArmorFilenamePrefix(armorFilenamePrefix);

ArmorMaterial armorMaterial = new ArmorMaterial(textureName, armorFilenamePrefix.length - 1, durability);
armorMaterial.withProtectionPercentage(DamageType.COMBAT,combat);
armorMaterial.withProtectionPercentage(DamageType.COMBAT, combat);
armorMaterial.withProtectionPercentage(DamageType.BLAST, blast);
armorMaterial.withProtectionPercentage(DamageType.FIRE, fire);
armorMaterial.withProtectionPercentage(DamageType.FALL, fall);
ArmorMaterial armorMaterial = new ArmorMaterial(textureName, ArmorMaterial.getArmorMaterials().size()-1, durability)
.withProtectionPercentage(DamageType.COMBAT, combat)
.withProtectionPercentage(DamageType.BLAST, blast)
.withProtectionPercentage(DamageType.FIRE, fire)
.withProtectionPercentage(DamageType.FALL, fall);
ArmorMaterial.register(armorMaterial);

return armorMaterial;
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/turniplabs/halplibe/helper/BlockBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

public class BlockBuilder implements Cloneable {
public static final Set<Integer> infiniburnList = new TreeSet<>();
static {
infiniburnList.add(Block.netherrack.id);
}

private final String MOD_ID;
private Float hardness = null;
Expand Down Expand Up @@ -461,11 +464,11 @@ public Block build(Block block) {
}

if (luminance != null) {
((BlockAccessor) block).callSetLightValue(luminance);
block.withLightEmission(luminance);
}

if (lightOpacity != null) {
((BlockAccessor) block).callSetLightOpacity(lightOpacity);
block.withLightBlock(lightOpacity);
}

if (slipperiness != null) {
Expand All @@ -490,7 +493,7 @@ public Block build(Block block) {
((BlockAccessor) block).callWithDisabledNeighborNotifyOnMetadataChange();
}

((BlockAccessor) block).callSetTickOnLoad(tickOnLoad);
block.setTicking(tickOnLoad);

if (blockDrop != null) {
((BlockAccessor) block).callSetDropOverride(blockDrop);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/turniplabs/halplibe/helper/BlockCoords.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static int[] nextCoords() {
lastX = 22;
if (++lastY > Global.TEXTURE_ATLAS_WIDTH_TILES-1) {
area = 1;
lastX = 7;
lastX = 10;
lastY = 16;
}
}
Expand All @@ -27,7 +27,7 @@ public static int[] nextCoords() {
int x = lastX;
int y = lastY;
if (++lastX > 21) {
lastX = 7;
lastX = 10;
if (++lastY > 30) {
area = 2;
lastX = 16;
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 @@ -122,7 +122,7 @@ public static Block createBlock(String modId, Block block, BlockSound blockSound
BlockSoundDispatcher.getInstance().addDispatch(block, blockSound);
((BlockAccessor) block).callSetHardness(hardness);
((BlockAccessor) block).callSetResistance(resistance);
((BlockAccessor) block).callSetLightValue(lightValue);
block.withLightEmission(lightValue);

Item.itemsList[block.id] = new ItemBlock(block);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/turniplabs/halplibe/helper/ParticleHelper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package turniplabs.halplibe.helper;


import net.minecraft.core.entity.fx.EntityFX;

import net.minecraft.client.entity.fx.EntityFX;

import java.util.HashMap;
import java.util.Map;
Expand Down
171 changes: 9 additions & 162 deletions src/main/java/turniplabs/halplibe/helper/RecipeHelper.java
Original file line number Diff line number Diff line change
@@ -1,146 +1,41 @@
package turniplabs.halplibe.helper;

import net.minecraft.core.block.Block;
import net.minecraft.core.crafting.CraftingManager;
import net.minecraft.core.crafting.recipe.*;
import net.minecraft.core.crafting.legacy.CraftingManager;
import net.minecraft.core.crafting.legacy.recipe.RecipesBlastFurnace;
import net.minecraft.core.crafting.legacy.recipe.RecipesFurnace;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import turniplabs.halplibe.HalpLibe;
import turniplabs.halplibe.mixin.accessors.CraftingManagerAccessor;
import turniplabs.halplibe.mixin.accessors.RecipesBlastFurnaceAccessor;
import turniplabs.halplibe.mixin.accessors.RecipesFurnaceAccessor;

import java.util.List;
import java.util.Map;

@Deprecated
public class RecipeHelper {
@Deprecated
public static final CraftingManager craftingManager = CraftingManager.getInstance();
public static final RecipesFurnace smeltingManager = RecipesFurnace.getInstance();
public static final RecipesBlastFurnace blastingManager = RecipesBlastFurnace.getInstance();
@Deprecated
public static final RecipesFurnace smeltingManager = RecipesFurnace.smelting();
@Deprecated
public static final RecipesBlastFurnace blastingManager = RecipesBlastFurnace.smelting();

@Deprecated
public static void removeRecipe(Item outputItem, int meta) {
List<IRecipe> recipes = craftingManager.getRecipeList();
IRecipe theRecipe = null;

for (IRecipe recipe : recipes) {
if (recipe instanceof RecipeShaped && ((RecipeShaped) recipe).recipeOutput.itemID == outputItem.id && ((RecipeShaped) recipe).recipeOutput.getMetadata() == meta) {
theRecipe = recipe;
break;
} else if (recipe instanceof RecipeShapeless && ((RecipeShapeless) recipe).recipeOutput.itemID == outputItem.id && ((RecipeShapeless) recipe).recipeOutput.getMetadata() == meta) {
theRecipe = recipe;
break;
}
}

if (theRecipe == null) {
HalpLibe.LOGGER.debug("Couldn't find recipe with output: " + outputItem.getKey());
return;
}

recipes.remove(theRecipe);
((CraftingManagerAccessor) craftingManager).setRecipes(recipes);
}

@Deprecated
public static void removeRecipe(Block outputBlock, int meta) {
List<IRecipe> recipes = craftingManager.getRecipeList();
IRecipe theRecipe = null;

for (IRecipe recipe : recipes) {
if (recipe instanceof RecipeShaped && ((RecipeShaped) recipe).recipeOutput.itemID == outputBlock.id && ((RecipeShaped) recipe).recipeOutput.getMetadata() == meta) {
theRecipe = recipe;
break;
} else if (recipe instanceof RecipeShapeless && ((RecipeShapeless) recipe).recipeOutput.itemID == outputBlock.id && ((RecipeShapeless) recipe).recipeOutput.getMetadata() == meta) {
theRecipe = recipe;
break;
}
}

if (theRecipe == null) {
HalpLibe.LOGGER.debug("Couldn't find crafting recipe with output: " + outputBlock.getKey());
return;
}

recipes.remove(theRecipe);
((CraftingManagerAccessor) craftingManager).setRecipes(recipes);
}

@Deprecated
public static class Crafting {

public static void createRecipe(Item outputItem, int amount, Object[] aobj) {
((CraftingManagerAccessor) craftingManager).callAddRecipe(new ItemStack(outputItem, amount), aobj);
}

public static void createRecipe(Block outputBlock, int amount, Object[] aobj) {
((CraftingManagerAccessor) craftingManager).callAddRecipe(new ItemStack(outputBlock, amount), aobj);
}

public static void createShapelessRecipe(Item outputItem, int amount, Object[] aobj) {
((CraftingManagerAccessor) craftingManager).callAddShapelessRecipe(new ItemStack(outputItem, amount), aobj);
craftingManager.addShapelessRecipe(new ItemStack(outputItem, amount), aobj);
}

public static void createShapelessRecipe(Block outputBlock, int amount, Object[] aobj) {
((CraftingManagerAccessor) craftingManager).callAddShapelessRecipe(new ItemStack(outputBlock, amount), aobj);
craftingManager.addShapelessRecipe(new ItemStack(outputBlock, amount), aobj);
}

public static void createRecipe(ItemStack stack, Object[] aobj) {
((CraftingManagerAccessor) craftingManager).callAddRecipe(stack, aobj);
craftingManager.addRecipe(stack, aobj);
}

public static void createShapelessRecipe(ItemStack stack, Object[] aobj) {
((CraftingManagerAccessor) craftingManager).callAddShapelessRecipe(stack, aobj);
}

public static void removeRecipe(Item outputItem) {
List<IRecipe> recipes = craftingManager.getRecipeList();
IRecipe theRecipe = null;

for (IRecipe recipe : recipes) {
if (recipe instanceof RecipeShaped && ((RecipeShaped) recipe).recipeOutput.itemID == outputItem.id) {
theRecipe = recipe;
break;
} else if (recipe instanceof RecipeShapeless && ((RecipeShapeless) recipe).recipeOutput.itemID == outputItem.id) {
theRecipe = recipe;
break;
}
}

if (theRecipe == null) {
HalpLibe.LOGGER.debug("Couldn't find recipe with output: " + outputItem.getKey());
return;
}

recipes.remove(theRecipe);
((CraftingManagerAccessor) craftingManager).setRecipes(recipes);
}

public static void removeRecipe(Block outputBlock) {
List<IRecipe> recipes = craftingManager.getRecipeList();
IRecipe theRecipe = null;

for (IRecipe recipe : recipes) {
if (recipe instanceof RecipeShaped && ((RecipeShaped) recipe).recipeOutput.itemID == outputBlock.id) {
theRecipe = recipe;
break;
} else if (recipe instanceof RecipeShapeless && ((RecipeShapeless) recipe).recipeOutput.itemID == outputBlock.id) {
theRecipe = recipe;
break;
}
}

if (theRecipe == null) {
HalpLibe.LOGGER.debug("Couldn't find crafting recipe with output: " + outputBlock.getKey());
return;
}

recipes.remove(theRecipe);
((CraftingManagerAccessor) craftingManager).setRecipes(recipes);
craftingManager.addShapelessRecipe(stack, aobj);
}
}
@Deprecated
Expand All @@ -161,30 +56,6 @@ public static void createRecipe(Block outputItem, Item inputItem) {
public static void createRecipe(Block outputItem, Block inputItem) {
smeltingManager.addSmelting(inputItem.id, new ItemStack(outputItem));
}

public static void removeRecipe(Item inputItem) {
Map recipes = smeltingManager.getSmeltingList();

if (!recipes.containsKey(inputItem)) {
HalpLibe.LOGGER.debug("Couldn't find smelting recipe with input: " + inputItem.getKey());
return;
}

recipes.remove(inputItem);
((RecipesFurnaceAccessor) smeltingManager).setSmeltingList(recipes);
}

public static void removeRecipe(Block inputItem) {
Map recipes = smeltingManager.getSmeltingList();

if (!recipes.containsKey(inputItem)) {
HalpLibe.LOGGER.debug("Couldn't find smelting recipe with input: " + inputItem.getKey());
return;
}

recipes.remove(inputItem);
((RecipesFurnaceAccessor) smeltingManager).setSmeltingList(recipes);
}
}

@Deprecated
Expand All @@ -204,30 +75,6 @@ public static void createRecipe(Block outputItem, Item inputItem) {
public static void createRecipe(Block outputItem, Block inputItem) {
blastingManager.addSmelting(inputItem.id, new ItemStack(outputItem));
}

public static void removeRecipe(Item inputItem) {
Map recipes = blastingManager.getSmeltingList();

if (!recipes.containsKey(inputItem)) {
HalpLibe.LOGGER.debug("Couldn't find blasting recipe with input: " + inputItem.getKey());
return;
}

recipes.remove(inputItem);
((RecipesBlastFurnaceAccessor) blastingManager).setSmeltingList(recipes);
}

public static void removeRecipe(Block inputItem) {
Map recipes = blastingManager.getSmeltingList();

if (!recipes.containsKey(inputItem)) {
HalpLibe.LOGGER.debug("Couldn't find blasting recipe with input: " + inputItem.getKey());
return;
}

recipes.remove(inputItem);
((RecipesBlastFurnaceAccessor) blastingManager).setSmeltingList(recipes);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ public interface BlockAccessor {
@Invoker("withBlastResistance")
Block callSetResistance(float f);

@Invoker("withLightOpacity")
Block callSetLightOpacity(int i);

@Invoker("withLightValue")
Block callSetLightValue(float f);

@Invoker("withLightValue")
Block callSetLightValue(int i);

@Invoker("withImmovableFlagSet")
Block callSetImmovable();

Expand All @@ -31,13 +22,9 @@ public interface BlockAccessor {

@Invoker("withLitInteriorSurface")
Block callSetIsLitInteriorSurface(boolean isLit);

@Invoker
Block callWithDisabledNeighborNotifyOnMetadataChange();

@Invoker
Block callSetTickOnLoad(boolean tickOnLoad);

@Accessor("key")
void halplibe$setKey(String key);
}
Loading
Loading