Skip to content

Commit

Permalink
cleavers and skeleton nerf
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigereye504 committed Mar 30, 2021
1 parent 582fa20 commit 2204792
Show file tree
Hide file tree
Showing 56 changed files with 473 additions and 135 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ dependencies {
// These are optional dependencies, though best as I can tell gradlew doesn't care
//modApi "com.github.moriyashiine:anthropophagy-1.16.5-1"
// modImplementation "com.github.LudoCrypt:the-backrooms:1.3.0"
implementation "me.zeroeightsix:fiber:${project.fiber_version}"
//implementation "me.zeroeightsix:fiber:${project.fiber_version}"
modImplementation "io.github.ladysnake:requiem-api:${requiem_version}"
modRuntime "io.github.ladysnake:requiem:${requiem_version}"
//modRuntime "io.github.ladysnake:requiem:${requiem_version}"
//modApi "io.github.ladysnake:requiem:${requiem_version}"
//compileOnly "io.github.ladysnake:requiem:${requiem_version}"

Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.11.2

# Mod Properties
mod_version = 2.9.1
mod_version = 2.9.2.pre1
maven_group = net.tigereye.chestcavity
archives_base_name = chestcavity

Expand All @@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx1G
fabric_version=0.31.0+1.16

# Requiem mod
requiem_version = 1.4.4
requiem_version = 1.5.1
fiber_version = 0.23.0-2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import net.minecraft.nbt.ListTag;
import net.tigereye.chestcavity.chestcavities.instance.ChestCavityInstance;

import java.util.ArrayList;
import java.util.List;

public class ChestCavityInventory extends SimpleInventory {

ChestCavityInstance instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public interface ChestCavityType {
public Map<Identifier,Float> getDefaultOrganScores();
public float getDefaultOrganScore(Identifier id);
public ChestCavityInventory getDefaultChestCavity();
//public boolean isSlotForbidden(int index);
public boolean isSlotForbidden(int index);

public void fillChestCavityInventory(ChestCavityInventory chestCavity);
//public void shapeChestCavity();
public void shapeChestCavity();
public void loadBaseOrganScores(Map<Identifier, Float> organScores);
public boolean catchExceptionalOrgan(ItemStack slot,Map<Identifier, Float> organScores);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public float getOldOrganScore(Identifier id) {
}

public void onInventoryChanged(Inventory sender) {
ChestCavityUtil.clearForbiddenSlots(this);
ChestCavityUtil.evaluateChestCavity(this);
}

Expand Down Expand Up @@ -170,10 +171,10 @@ public void clone(ChestCavityInstance other) {
inventory.removeListener(this);
}
catch(NullPointerException ignored){}
//for(int i = 0; i < inventory.size(); ++i) {
// inventory.setStack(i, other.inventory.getStack(i));
// inventory.forbiddenSlots = other.inventory.forbiddenSlots;
//}
for(int i = 0; i < inventory.size(); ++i) {
inventory.setStack(i, other.inventory.getStack(i));
//inventory.forbiddenSlots = other.inventory.forbiddenSlots;
}
inventory.readTags(other.inventory.getTags());
inventory.addListener(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ public class BaseChestCavity implements ChestCavityType {

private Map<Identifier,Float> defaultOrganScores = null;
private ChestCavityInventory defaultChestCavity = new ChestCavityInventory();
//public boolean[] forbiddenSlots;
public List<Integer> forbiddenSlots = new ArrayList<>();

public BaseChestCavity(){
fillChestCavityInventory(defaultChestCavity);
shapeChestCavity();
}

@Override
Expand All @@ -38,28 +39,24 @@ public Map<Identifier,Float> getDefaultOrganScores(){
public float getDefaultOrganScore(Identifier id){return getDefaultOrganScores().getOrDefault(id,0f);}
@Override
public ChestCavityInventory getDefaultChestCavity(){return defaultChestCavity;}
/*

@Override
public boolean isSlotForbidden(int index){
if(forbiddenSlots.length < index){
return true;
}
return forbiddenSlots[index];
return forbiddenSlots.contains(index);
}
*/

@Override
public void fillChestCavityInventory(ChestCavityInventory chestCavity) {
chestCavity.clear();
for(int i = 0; i < chestCavity.size(); i++){
chestCavity.setStack(i,new ItemStack(Items.DIRT,64));
}
}
/*

@Override
public void shapeChestCavity() {
forbiddenSlots = new boolean[getDefaultChestCavity().size()];
}
*/

@Override
public void loadBaseOrganScores(Map<Identifier, Float> organScores){
organScores.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,33 @@ public void fillChestCavityInventory(ChestCavityInventory chestCavity) {
chestCavity.setStack(15, ItemStack.EMPTY);
chestCavity.setStack(16, new ItemStack(CCItems.ROTTEN_RIB, CCItems.ROTTEN_RIB.getMaxCount()));
}
/*

@Override
public void shapeChestCavity() {
forbiddenSlots = new boolean[getDefaultChestCavity().size()];
forbiddenSlots[0] = true;
forbiddenSlots[8] = true;
forbiddenSlots[9] = true;
forbiddenSlots[17] = true;
forbiddenSlots[18] = true;
forbiddenSlots[19] = true;
forbiddenSlots[20] = true;
forbiddenSlots[21] = true;
forbiddenSlots[22] = true;
forbiddenSlots[23] = true;
forbiddenSlots[24] = true;
forbiddenSlots[25] = true;
forbiddenSlots[26] = true;
forbiddenSlots.add(0);
forbiddenSlots.add(2);
forbiddenSlots.add(3);
forbiddenSlots.add(4);
forbiddenSlots.add(5);
forbiddenSlots.add(6);
forbiddenSlots.add(8);
forbiddenSlots.add(9);
forbiddenSlots.add(11);
forbiddenSlots.add(12);
forbiddenSlots.add(14);
forbiddenSlots.add(15);
forbiddenSlots.add(17);
forbiddenSlots.add(18);
forbiddenSlots.add(19);
forbiddenSlots.add(20);
forbiddenSlots.add(21);
forbiddenSlots.add(22);
forbiddenSlots.add(23);
forbiddenSlots.add(24);
forbiddenSlots.add(25);
forbiddenSlots.add(26);
}
*/

@Override
public void loadBaseOrganScores(Map<Identifier, Float> organScores){
organScores.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ public void fillChestCavityInventory(ChestCavityInventory chestCavity) {
chestCavity.setStack(26, ItemStack.EMPTY);
}

@Override
public void shapeChestCavity() {
forbiddenSlots.add(0);
forbiddenSlots.add(2);
forbiddenSlots.add(3);
forbiddenSlots.add(4);
forbiddenSlots.add(5);
forbiddenSlots.add(6);
forbiddenSlots.add(8);
forbiddenSlots.add(9);
forbiddenSlots.add(11);
forbiddenSlots.add(12);
forbiddenSlots.add(14);
forbiddenSlots.add(15);
forbiddenSlots.add(17);
forbiddenSlots.add(18);
forbiddenSlots.add(19);
forbiddenSlots.add(20);
forbiddenSlots.add(21);
forbiddenSlots.add(22);
forbiddenSlots.add(23);
forbiddenSlots.add(24);
forbiddenSlots.add(25);
forbiddenSlots.add(26);
}

@Override
public void loadBaseOrganScores(Map<Identifier, Float> organScores){
organScores.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
import net.minecraft.loot.BinomialLootTableRange;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SmeltingRecipe;
import net.minecraft.util.Identifier;
import net.tigereye.chestcavity.ChestCavity;
import net.tigereye.chestcavity.chestcavities.instance.ChestCavityInstance;
import net.tigereye.chestcavity.interfaces.ChestCavityEntity;
import net.tigereye.chestcavity.recipes.SalvageRecipe;
import net.tigereye.chestcavity.registration.CCItems;
import net.tigereye.chestcavity.registration.CCRecipes;
import net.tigereye.chestcavity.registration.CCTags;
import net.tigereye.modifydropsapi.api.GenerateBlockLootCallbackModifyLoot;
import net.tigereye.modifydropsapi.api.GenerateEntityLootCallbackAddLoot;
import net.tigereye.modifydropsapi.api.GenerateEntityLootCallbackModifyLoot;

import java.util.*;

Expand Down Expand Up @@ -52,7 +58,12 @@ public static void register(){
}
//get looting level and random
if(lootContext.get(LootContextParameters.KILLER_ENTITY) instanceof LivingEntity){
lootingLevel = EnchantmentHelper.getLooting((LivingEntity) lootContext.get(LootContextParameters.KILLER_ENTITY));
LivingEntity killer = (LivingEntity) lootContext.get(LootContextParameters.KILLER_ENTITY);
lootingLevel = EnchantmentHelper.getLooting(killer);
if(killer.getStackInHand(killer.getActiveHand()).getItem().isIn(CCTags.BUTCHERING_TOOL))
{
lootingLevel += 3;
}
random = lootContext.getRandom();
}
else{
Expand All @@ -66,6 +77,37 @@ public static void register(){
return loot;
});

GenerateEntityLootCallbackModifyLoot.EVENT.register((type,lootContext,loot) -> {
if (lootContext.hasParameter(LootContextParameters.KILLER_ENTITY)) {
LivingEntity killer = (LivingEntity) lootContext.get(LootContextParameters.KILLER_ENTITY);
if(killer.getStackInHand(killer.getActiveHand()).getItem().isIn(CCTags.BUTCHERING_TOOL)){
//first, remove everything that can be salvaged from the loot and count them up
Map<SalvageRecipe, Integer> salvageResults = new HashMap<>();
Iterator<ItemStack> i = loot.iterator();
while(i.hasNext()){
ItemStack stack = i.next();
List<SalvageRecipe> recipes = killer.world.getRecipeManager().listAllOfType(CCRecipes.SALVAGE_RECIPE_TYPE);
if(stack.getItem().isIn(CCTags.SALVAGEABLE)){
for (SalvageRecipe recipe: recipes) {
if(recipe.getInput().test(stack)){
salvageResults.put(recipe,salvageResults.getOrDefault(recipe,0)+stack.getCount());
i.remove();
break;
}
}
}
}
//then, get the output of the salvage and add it to the loot
salvageResults.forEach((recipe,count) -> {
ItemStack out = recipe.getOutput();
out.setCount(out.getCount()*(count/recipe.getRequired()));
loot.add(out);
});
}
}
return loot;
});

LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
if (DESERT_PYRAMID_LOOT_TABLE_ID.equals(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Identifier getId() {
public RecipeSerializer<?> getSerializer() {
return SalvageRecipeSerializer.INSTANCE;
}
/*

public static class Type implements RecipeType<SalvageRecipe> {
// Define ExampleRecipe.Type as a singleton by making its constructor private and exposing an instance.
private Type() {}
Expand All @@ -114,5 +114,5 @@ private Type() {}
public RecipeType<?> getType() {
return Type.INSTANCE;
}
*/

}
14 changes: 14 additions & 0 deletions src/main/java/net/tigereye/chestcavity/registration/CCItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterials;
import net.minecraft.util.registry.Registry;

import net.tigereye.chestcavity.ChestCavity;
Expand All @@ -14,6 +16,12 @@ public class CCItems {
public static final Item.Settings FOOD_ITEM_SETTINGS = new Item.Settings().maxCount(64).group(ItemGroup.FOOD);

public static final Item CHEST_OPENER = new ChestOpener();
public static final SwordItem WOODEN_CLEAVER = new SwordItem(ToolMaterials.WOOD,6,-3.2f,new Item.Settings().group(ItemGroup.COMBAT));
public static final SwordItem GOLD_CLEAVER = new SwordItem(ToolMaterials.GOLD,6,-3.0f,new Item.Settings().group(ItemGroup.COMBAT));
public static final SwordItem STONE_CLEAVER = new SwordItem(ToolMaterials.STONE,7,-3.2f,new Item.Settings().group(ItemGroup.COMBAT));
public static final SwordItem IRON_CLEAVER = new SwordItem(ToolMaterials.IRON,6,-3.1f,new Item.Settings().group(ItemGroup.COMBAT));
public static final SwordItem DIAMOND_CLEAVER = new SwordItem(ToolMaterials.DIAMOND,5,-3.0f,new Item.Settings().group(ItemGroup.COMBAT));
public static final SwordItem NETHERITE_CLEAVER = new SwordItem(ToolMaterials.NETHERITE,5,-3.0f,new Item.Settings().group(ItemGroup.COMBAT).fireproof());

public static final Organ HUMAN_APPENDIX = new Organ().setOrganQuality(CCOrganScores.LUCK,1f);
public static final Organ HUMAN_HEART = new Organ().setOrganQuality(CCOrganScores.HEALTH,1f);
Expand Down Expand Up @@ -183,6 +191,12 @@ public class CCItems {
public static final Item CUD = new Item(FOOD_ITEM_SETTINGS.food(CCFoodComponents.CUD_FOOD_COMPONENT));
public static void register() {
registerItem("chest_opener", CHEST_OPENER);
registerItem("wooden_cleaver", WOODEN_CLEAVER);
registerItem("stone_cleaver", STONE_CLEAVER);
registerItem("gold_cleaver", GOLD_CLEAVER);
registerItem("iron_cleaver", IRON_CLEAVER);
registerItem("diamond_cleaver", DIAMOND_CLEAVER);
registerItem("netherite_cleaver", NETHERITE_CLEAVER);

registerItem("appendix", HUMAN_APPENDIX);
registerItem("heart", HUMAN_HEART);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.tigereye.chestcavity.registration;

import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SpecialRecipeSerializer;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
Expand All @@ -11,11 +12,11 @@
public class CCRecipes {
public static SpecialRecipeSerializer<InfuseVenomGland> INFUSE_VENOM_GLAND;
public static SalvageRecipeSerializer SALVAGE_RECIPE_SERIALIZER;
//public static SalvageRecipe SALVAGE_RECIPE_TYPE;
public static RecipeType<SalvageRecipe> SALVAGE_RECIPE_TYPE;

public static void register() {
INFUSE_VENOM_GLAND = (SpecialRecipeSerializer<InfuseVenomGland>) Registry.register(Registry.RECIPE_SERIALIZER, "crafting_special_infuse_venom_gland", new SpecialRecipeSerializer<InfuseVenomGland>(InfuseVenomGland::new));
SALVAGE_RECIPE_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, SalvageRecipeSerializer.ID, SalvageRecipeSerializer.INSTANCE);
//Registry.register(Registry.RECIPE_TYPE, SalvageRecipeSerializer.ID, SalvageRecipe.Type.INSTANCE);
SALVAGE_RECIPE_TYPE = Registry.register(Registry.RECIPE_TYPE, SalvageRecipeSerializer.ID, SalvageRecipe.Type.INSTANCE);
}
}
11 changes: 2 additions & 9 deletions src/main/java/net/tigereye/chestcavity/registration/CCTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
import net.tigereye.chestcavity.ChestCavity;

public class CCTags {
public static final Tag<Item> HUMAN_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"human_organs"));
public static final Tag<Item> UNDEAD_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"undead_organs"));
public static final Tag<Item> ANIMAL_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"animal_organs"));
public static final Tag<Item> SMALL_ANIMAL_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"small_animal_organs"));
public static final Tag<Item> BUTCHERING_TOOL = TagRegistry.item(new Identifier(ChestCavity.MODID,"butchering_tool"));
public static final Tag<Item> ROTTEN_FOOD = TagRegistry.item(new Identifier(ChestCavity.MODID,"rotten_food"));
//used in crafting recipes, though currently unused outside of JSONs
public static final Tag<Item> SALVAGEABLE_ROTTEN_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"salvageable_rotten_organs"));
public static final Tag<Item> SALVAGEABLE_ANIMAL_MEAT_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"salvageable_animal_meat_organs"));
public static final Tag<Item> SALVAGEABLE_SMALL_ANIMAL_MEAT_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"salvageable_small_animal_meat_organs"));
public static final Tag<Item> SALVAGEABLE_BONE_ORGANS = TagRegistry.item(new Identifier(ChestCavity.MODID,"salvageable_bone_organs"));
public static final Tag<Item> SALVAGEABLE = TagRegistry.item(new Identifier(ChestCavity.MODID,"salvageable"));
}
14 changes: 13 additions & 1 deletion src/main/java/net/tigereye/chestcavity/util/ChestCavityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static boolean determineDefaultOrganScores(ChestCavityType chestCavityTyp

public static void dropUnboundOrgans(ChestCavityInstance cc) {
if(ChestCavity.config.REQUIEM_INTEGRATION){
if(Registry.ENTITY_TYPE.getId(cc.owner.getType()) == CCRequiem.PLAYER_SHELL_ID){
if(Registry.ENTITY_TYPE.getId(cc.owner.getType()).compareTo(CCRequiem.PLAYER_SHELL_ID) == 0){
return; //player shells shall not drop organs
}
}
Expand Down Expand Up @@ -482,4 +482,16 @@ public static float applySwimSpeedInWater(ChestCavityInstance cc) {
}

}

public static void clearForbiddenSlots(ChestCavityInstance cc) {
try {
cc.inventory.removeListener(cc);
} catch(NullPointerException ignored){}
for(int i = 0; i < cc.inventory.size();i++){
if(cc.getChestCavityType().isSlotForbidden(i)){
cc.owner.dropStack(cc.inventory.removeStack(i));
}
}
cc.inventory.addListener(cc);
}
}
Loading

0 comments on commit 2204792

Please sign in to comment.