Skip to content

Commit

Permalink
Update slime drops for 1.19 changes
Browse files Browse the repository at this point in the history
Fix slimes dropping balls when not small
Fix slimes not interacting with frogs (#5218)
  • Loading branch information
KnightMiner committed May 13, 2024
1 parent d1994b6 commit 1465de3
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": [
"tconstruct:sky_slime",
"tconstruct:ender_slime",
"tconstruct:terracube"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,34 @@
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "slime",
"size": 1
}
}
}
],
"entries": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:frog"
}
}
}
}
],
"functions": [
{
"add": false,
Expand All @@ -26,6 +51,27 @@
}
],
"name": "tconstruct:ender_slime_ball"
},
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:frog"
}
}
}
],
"functions": [
{
"add": false,
"count": 1.0,
"function": "minecraft:set_count"
}
],
"name": "tconstruct:ender_slime_ball"
}
],
"rolls": 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,34 @@
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "slime",
"size": 1
}
}
}
],
"entries": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:frog"
}
}
}
}
],
"functions": [
{
"add": false,
Expand All @@ -26,6 +51,27 @@
}
],
"name": "tconstruct:sky_slime_ball"
},
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:frog"
}
}
}
],
"functions": [
{
"add": false,
"count": 1.0,
"function": "minecraft:set_count"
}
],
"name": "tconstruct:sky_slime_ball"
}
],
"rolls": 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@
"entries": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:inverted",
"term": {
"condition": "minecraft:damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:frog"
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"type_specific": {
"type": "slime",
"size": {
"min": 2
}
}
}
}
],
"functions": [
{
"add": false,
Expand All @@ -23,23 +48,46 @@
"min": 0.0
},
"function": "minecraft:looting_enchant"
},
}
],
"name": "minecraft:clay_ball"
},
{
"type": "minecraft:item",
"conditions": [
{
"conditions": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"flags": {
"is_on_fire": true
}
}
"condition": "minecraft:damage_source_properties",
"predicate": {
"source_entity": {
"type": "minecraft:frog"
}
],
"function": "minecraft:furnace_smelt"
}
}
],
"name": "minecraft:clay_ball"
"functions": [
{
"add": false,
"count": 1.0,
"function": "minecraft:set_count"
}
],
"name": "tconstruct:seared_cobble"
}
],
"functions": [
{
"conditions": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"flags": {
"is_on_fire": true
}
}
}
],
"function": "minecraft:furnace_smelt"
}
],
"rolls": 1.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package slimeknights.tconstruct.common.data.loot;

import net.minecraft.advancements.critereon.DamageSourcePredicate;
import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.advancements.critereon.SlimePredicate;
import net.minecraft.data.loot.EntityLoot;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootPool;
Expand All @@ -10,13 +15,16 @@
import net.minecraft.world.level.storage.loot.functions.LootingEnchantFunction;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.functions.SmeltItemFunction;
import net.minecraft.world.level.storage.loot.predicates.DamageSourceCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import net.minecraftforge.registries.ForgeRegistries;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.shared.TinkerCommons;
import slimeknights.tconstruct.shared.block.SlimeType;
import slimeknights.tconstruct.smeltery.TinkerSmeltery;
import slimeknights.tconstruct.world.TinkerWorld;

import java.util.Map.Entry;
Expand All @@ -43,14 +51,43 @@ protected void addTables() {
.apply(SetItemCountFunction.setCount(UniformGenerator.between(-2.0F, 1.0F)))
.apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(0.0F, 1.0F)))
.apply(SmeltItemFunction.smelted().when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, ENTITY_ON_FIRE))))));

LootItemCondition.Builder killedByFrog = killedByFrog();
this.add(TinkerWorld.terracubeEntity.get(),
LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(Items.CLAY_BALL)
.apply(SetItemCountFunction.setCount(UniformGenerator.between(-2.0F, 1.0F)))
.apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(0.0F, 1.0F)))
.when(killedByFrog.invert())
.when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().subPredicate(SlimePredicate.sized(MinMaxBounds.Ints.atLeast(2))))))
.add(LootItem.lootTableItem(TinkerSmeltery.searedCobble) // TODO: can I come up with something more exciting?
.apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
.when(killedByFrog))
.apply(SmeltItemFunction.smelted().when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, ENTITY_ON_FIRE)))));



}

private static LootItemCondition.Builder killedByFrog() {
return DamageSourceCondition.hasDamageSource(DamageSourcePredicate.Builder.damageType().source(EntityPredicate.Builder.entity().of(EntityType.FROG)));
}

private static LootTable.Builder dropSlimeballs(SlimeType type) {
return LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(TinkerCommons.slimeball.get(type))
.apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F)))
.apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(0.0F, 1.0F)))));
LootItemCondition.Builder killedByFrog = killedByFrog();
Item slimeball = TinkerCommons.slimeball.get(type);
return LootTable.lootTable().withPool(
LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(slimeball)
.apply(SetItemCountFunction.setCount(UniformGenerator.between(0.0F, 2.0F)))
.apply(LootingEnchantFunction.lootingMultiplier(UniformGenerator.between(0.0F, 1.0F)))
.when(killedByFrog().invert()))
.add(LootItem.lootTableItem(slimeball)
.apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F)))
.when(killedByFrog))
.when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().subPredicate(SlimePredicate.sized(MinMaxBounds.Ints.exactly(1))))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.EntityTypeTagsProvider;
import net.minecraft.tags.EntityTypeTags;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.common.data.ExistingFileHelper;
import slimeknights.tconstruct.TConstruct;
Expand All @@ -19,6 +20,7 @@ public EntityTypeTagProvider(DataGenerator generatorIn, ExistingFileHelper exist
public void addTags() {
this.tag(TinkerTags.EntityTypes.SLIMES)
.add(EntityType.SLIME, TinkerWorld.skySlimeEntity.get(), TinkerWorld.enderSlimeEntity.get(), TinkerWorld.terracubeEntity.get());
this.tag(EntityTypeTags.FROG_FOOD).add(TinkerWorld.skySlimeEntity.get(), TinkerWorld.enderSlimeEntity.get(), TinkerWorld.terracubeEntity.get());
this.tag(TinkerTags.EntityTypes.BACON_PRODUCER).add(EntityType.PIG, EntityType.PIGLIN, EntityType.HOGLIN);

this.tag(TinkerTags.EntityTypes.MELTING_SHOW).add(EntityType.IRON_GOLEM, EntityType.SNOW_GOLEM, EntityType.VILLAGER, EntityType.PLAYER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ protected void populateDefaultEquipmentSlots(RandomSource random, DifficultyInst
// 2.5% chance of plate
boolean isPlate = this.random.nextFloat() < (0.05f * multiplier);
// TODO: allow adding more helmet types, unfortunately tags don't let me add chances
// TODO: randomize plate materials
ItemStack helmet = new ItemStack((isPlate ? TinkerTools.plateArmor : TinkerTools.travelersGear).get(ArmorSlotType.HELMET));

// for plate, just init stats
Expand Down

0 comments on commit 1465de3

Please sign in to comment.