Skip to content

Commit

Permalink
fixed wendigoism bug, updated dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigereye504 committed Oct 9, 2020
1 parent e3beb35 commit 33918d0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
// Replace modImplementation with modApi if you expose components in your own API
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:2.6.0"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:2.6.0"
modImplementation "com.github.tigereye504:modify-drops-api:0.2.1"
modApi "com.github.tigereye504:modify-drops-api:0.3.1"
modApi("me.shedaniel.cloth:config-2:4.8.2") {
exclude(group: "net.fabricmc.fabric-api")
}
Expand All @@ -39,7 +39,7 @@ dependencies {
// Jar-in-Jar dependencies
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:2.6.0"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:2.6.0"
include "com.github.tigereye504:modify-drops-api:0.2.1"
include "com.github.tigereye504:modify-drops-api:0.3.1"
include "me.shedaniel.cloth:config-2:4.8.2"
include "me.sargunvohra.mcmods:autoconfig1u:3.2.2"
}
Expand Down
2 changes: 1 addition & 1 deletion 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.10.1+build.209

# Mod Properties
mod_version = 1.3.0
mod_version = 1.3.1
maven_group = net.tigereye.chestcavity
archives_base_name = chestcavity

Expand Down
16 changes: 13 additions & 3 deletions src/main/java/net/tigereye/chestcavity/components/CCComponent.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.tigereye.chestcavity.components;

//import dev.onyxstudios.cca.api.v3.util.PlayerComponent;
import net.minecraft.world.GameRules;
import net.tigereye.chestcavity.items.CCItems;
import net.tigereye.chestcavity.listeners.*;

Expand Down Expand Up @@ -120,7 +121,9 @@ public void initChestCavityInventory()
}

public void chestCavityPostMortem(){
rejectForeignObjects();
if(owner.getEntityWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
rejectForeignObjects();
}
insertWelfareOrgans();
}

Expand All @@ -146,9 +149,16 @@ private void insertWelfareOrgans(){
}

private void forcefullyAddStack(ItemStack stack, int slot){
if(!inventory.canInsert(stack)){
if(inventory.canInsert(stack)){
inventory.addStack(stack);
}
else if(owner.getEntityWorld().getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
if(!owner.inventory.insertStack(stack)){
owner.dropStack(inventory.removeStack(slot));
}
}
else {
owner.dropStack(inventory.removeStack(slot));
}
inventory.addStack(stack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class CCWendigoismItems {
public static final Identifier ORGANS_CANNIBAL_HEART = new Identifier(ChestCavity.MODID, "organs_cannibal_heart");
public static final Identifier ORGANS_TETHERED_CANNIBAL_HEART = new Identifier(ChestCavity.MODID, "organs_tethered_cannibal_heart");

private static final Identifier WENDIGOISM_FLESH = new Identifier("wendigoism", "flesh");
private static final Identifier WENDIGOISM_CORRUPT_FLESH = new Identifier("wendigoism", "corrupt_flesh");

public static final Item CANNIBAL_HEART = new OrganBase()
.setOrganQuality(CCItems.ORGANS_HEART,.5f)
.setOrganQuality(ORGANS_CANNIBAL_HEART,1);
Expand All @@ -38,12 +41,12 @@ private static void registerItem(String name, Item item) {
}

private static void addWindegoismHeartsToExternalOrgans(int i, Identifier identifier, Item item) {
if(item == WDItems.FLESH){
if(identifier == WENDIGOISM_FLESH){
Map<Identifier,Float> flesh = new HashMap<>();
flesh.put(CCItems.ORGANS_MUSCLE,1f);
VanillaOrgans.map.put(WDItems.FLESH,flesh);
}
if(item == WDItems.CORRUPT_FLESH){
if(identifier == WENDIGOISM_CORRUPT_FLESH){
Map<Identifier,Float> corruptedFlesh = new HashMap<>();
corruptedFlesh.put(CCItems.ORGANS_MUSCLE,1f);
VanillaOrgans.map.put(WDItems.CORRUPT_FLESH,corruptedFlesh);
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/net/tigereye/chestcavity/listeners/LootRegister.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.*;
import net.minecraft.entity.passive.AnimalEntity;
Expand All @@ -11,11 +12,13 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.BinomialLootTableRange;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.util.Identifier;
import net.tigereye.chestcavity.ChestCavity;
import net.tigereye.chestcavity.items.CCItems;
import net.tigereye.modifydropsapi.api.LivingEntityDropLootCallback_AddDrops;
import net.tigereye.modifydropsapi.api.GenerateEntityLootCallbackAddLoot;

import java.util.ArrayList;
import java.util.LinkedList;
Expand All @@ -30,14 +33,15 @@ public class LootRegister {


public static void register(){
LivingEntityDropLootCallback_AddDrops.EVENT.register((entity, source, causedByPlayer) -> {
GenerateEntityLootCallbackAddLoot.EVENT.register((type, lootContext) -> {
List<ItemStack> loot = new ArrayList<>();
if (causedByPlayer) {
if (lootContext.hasParameter(LootContextParameters.LAST_DAMAGE_PLAYER)) {
int lootingLevel;
Random random;
if(source.getAttacker() instanceof LivingEntity){
lootingLevel = EnchantmentHelper.getLooting((LivingEntity) source.getAttacker());
random = ((LivingEntity) source.getAttacker()).getRandom();
Entity entity = lootContext.get(LootContextParameters.THIS_ENTITY);
if(lootContext.get(LootContextParameters.KILLER_ENTITY) instanceof LivingEntity){
lootingLevel = EnchantmentHelper.getLooting((LivingEntity) lootContext.get(LootContextParameters.KILLER_ENTITY));
random = lootContext.getRandom();
}
else{
lootingLevel = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.tigereye.modifydropsapi.api.BlockDropStacksCallback_AddDrops;

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

public interface OrganUpdateCallback {
Expand Down

0 comments on commit 33918d0

Please sign in to comment.