Skip to content

Commit

Permalink
Food-related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
beckadamtheinventor committed Feb 24, 2024
1 parent 8ed34bb commit a04883a
Show file tree
Hide file tree
Showing 20 changed files with 42 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# M3EC

## Minecraft Multi Mod Environment Compiler
Version 0.8
Version 0.9

This compiler/script operates on the mentality of "as few files as possible" to create a mod.
Check out the `testrubymod` folder for usage examples.
Expand Down
3 changes: 3 additions & 0 deletions _m3ec/gradle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ def maybe_run_gradle(path, modenv, javaver, md):
fname = "gradlew"

if "buildjar" in modenvlow or "build" in modenvlow:
print("\n-----------------------------------------------\n\tbuilding JAR\n")
subprocess.Popen([os.path.join(path, fname), "build", "jar", javapath], cwd=path).wait()
jd = os.path.join(os.path.dirname(path), "built_mod_jars")
make_dir(jd)
for f in walk(os.path.join(path, "build", "libs")):
shutil.copy(f, os.path.join(jd, os.path.splitext(os.path.basename(f))[0]+"-"+md["modloader"]+md["gameversion"]+".jar"))
if "runclient" in modenvlow:
print("\n-----------------------------------------------\n\tRunning Client\n")
subprocess.Popen([os.path.join(path, fname), "runClient", javapath], cwd=path).wait()
if "runserver" in modenvlow:
print("\n-----------------------------------------------\n\tRunning Server\n")
subprocess.Popen([os.path.join(path, fname), "runServer", javapath], cwd=path).wait()


Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.16.5/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.17.1/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.17/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.18.1/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.18.2/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.18/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.19.2/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.19.3/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.19.4/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.19/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
---iter moditems.imports
Expand Down
7 changes: 1 addition & 6 deletions data/fabric1.20.1/registry/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ToolItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.*;
import net.minecraft.util.Identifier;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
Expand Down
14 changes: 8 additions & 6 deletions data/fabric_common/classes/FoodItem.m3ecjava
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ${mod.package}.registry;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand All @@ -22,13 +23,14 @@ public class FoodItem extends Item {
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
TypedActionResult<ItemStack> result = super.use(world, user, hand);
if (result.getResult() == ActionResult.SUCCESS) {
if (returnItem != null) {
user.giveItemStack(new ItemStack(returnItem, 1));
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
ItemStack rval = super.finishUsing(stack, world, user);
if (this.isFood() && returnItem != null) {
if (user.isPlayer()) {
PlayerEntity player = world.getPlayerByUuid(user.getUuid());
player.giveItemStack(new ItemStack(returnItem, 1));
}
}
return result;
return rval;
}
}
2 changes: 1 addition & 1 deletion data/forge1.18.1/m3ec_build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"firstActions": [
{
"action": "print",
"string": "[!] Building for Forge 1.16.5 is currently *very* broken [!]"
"string": "[!] Building for Forge 1.18.1 is currently *very* broken [!]"
},
{
"if": [
Expand Down
4 changes: 3 additions & 1 deletion data/forge1.19.2/java/item/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public class ModItems {

---iter mod.registry.food.names
public static final RegistryObject<Item> ${mod.food.$%v.uppercased} = ITEMS.register("$%v",
() -> new Item(new Item.Properties().tab(${mod.creativemodetab}).food(ModFoods.${mod.food.$%v.uppercased})));---end
() -> new FoodItem(new Item.Properties().food(ModFoods.${mod.food.$%v.uppercased})
---if mod.food.$%v.returnItem
, ${mod.food.$%v.returnItem}---fi));---end

---iter mod.registry.tool.names
public static final RegistryObject<Item> ${mod.tool.$%v.uppercased} = ITEMS.register("$%v",
Expand Down
4 changes: 3 additions & 1 deletion data/forge1.19/java/item/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public class ModItems {

---iter mod.registry.food.names
public static final RegistryObject<Item> ${mod.food.$%v.uppercased} = ITEMS.register("$%v",
() -> new Item(new Item.Properties().tab(${mod.creativemodetab}).food(ModFoods.${mod.food.$%v.uppercased})));---end
() -> new FoodItem(new Item.Properties().food(ModFoods.${mod.food.$%v.uppercased})
---if mod.food.$%v.returnItem
, ${mod.food.$%v.returnItem}---fi));---end

---iter mod.registry.tool.names
public static final RegistryObject<Item> ${mod.tool.$%v.uppercased} = ITEMS.register("$%v",
Expand Down
4 changes: 2 additions & 2 deletions data/forge1.20.1/java/item/ModItems.m3ecjava
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class ModItems {

---iter mod.registry.food.names
public static final RegistryObject<Item> ${mod.food.$%v.uppercased} = ITEMS.register("$%v",
() -> new FoodItem(new Item.Properties().food(ModFoods.${mod.food.$%v.uppercased}))
() -> new FoodItem(new Item.Properties().food(ModFoods.${mod.food.$%v.uppercased})
---if mod.food.$%v.returnItem
, ${mod.food.$%v.returnItem}---fi);---end
, ${mod.food.$%v.returnItem}---fi));---end

---iter mod.registry.tool.names
public static final RegistryObject<Item> ${mod.tool.$%v.uppercased} = ITEMS.register("$%v",
Expand Down
15 changes: 9 additions & 6 deletions data/forge_common/classes/FoodItem.m3ecjava
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ${mod.package}.item;


import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -23,11 +23,14 @@ public class FoodItem extends Item {
}

@Override
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
InteractionResultHolder<ItemStack> result = super.use(pLevel, pPlayer, pUsedHand);
if (result.getResult() == InteractionResult.SUCCESS) {
pPlayer.addItem(new ItemStack(returnItem, 1));
public ItemStack finishUsingItem(ItemStack pStack, Level pLevel, LivingEntity pLivingEntity) {
ItemStack rval = super.finishUsingItem(pStack, pLevel, pLivingEntity);
if (pStack.isEdible() && returnItem != null) {
Player player = pLevel.getPlayerByUUID(pLivingEntity.getUUID());
if (player != null) {
player.addItem(new ItemStack(returnItem, 1));
}
}
return result;
return rval;
}
}
2 changes: 1 addition & 1 deletion m3ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def copy_textures(content_type, cid, manifest_dict, project_path, dest_dir):
if __name__=='__main__':
if len(sys.argv) < 2:
print("""
Minecraft Multiple Mod Environment Compiler v0.7
Minecraft Multiple Mod Environment Compiler v0.9
Usage:
python m3ec.py path modenv
where modenv can be any combination of:
Expand Down

0 comments on commit a04883a

Please sign in to comment.