mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Document the loot, drop, entity and sapling services and the item and entity values
This commit is contained in:
1 parent
93f1768174
commit
3633c105b4
4 files changed
+92
-2
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package com.volmit;
|
||||
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.item.ItemEnchantment;
|
||||
import com.volmit.service.BlockDrops;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.service.SaplingGrowth;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/** The values services hand the host are immutable and refuse what the host could not create. */
|
||||
class ItemAndEntityValuesTest {
|
||||
@Test
|
||||
void anItemDropRefusesNothingToDropAndKeepsItsListsApart() {
|
||||
assertThrows(IllegalArgumentException.class, () -> ItemDrop.of("stick", 0));
|
||||
|
||||
List<ItemEnchantment> enchantments = new ArrayList<>(List.of(new ItemEnchantment("sharpness", 3)));
|
||||
ItemDrop drop = new ItemDrop("diamond_sword", 1, null, List.of(), enchantments, List.of(), false, List.of(), null,
|
||||
0.25, null, null, Map.of(), null);
|
||||
enchantments.clear();
|
||||
|
||||
assertEquals(1, drop.enchantments().size());
|
||||
assertThrows(UnsupportedOperationException.class, () -> drop.enchantments().clear());
|
||||
assertThrows(IllegalArgumentException.class, () -> new ItemEnchantment("sharpness", 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEntityKnowsWhetherItIsAnotherPluginsMob() {
|
||||
EntitySpec zombie = entity("minecraft:zombie", "");
|
||||
EntitySpec special = entity("", "mythic:dragon");
|
||||
|
||||
assertFalse(zombie.isSpecial());
|
||||
assertTrue(special.isSpecial());
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAttemptSaysWhetherLightMatters() {
|
||||
BlockPosition at = new BlockPosition(1, 2, 3);
|
||||
EntitySpec zombie = entity("minecraft:zombie", "");
|
||||
|
||||
assertFalse(new EntitySpawns.Attempt(at, zombie, EntitySpawns.Surface.LAND, 0, 15, true).restrictsLight());
|
||||
assertTrue(new EntitySpawns.Attempt(at, zombie, EntitySpawns.Surface.LAND, 0, 7, true).restrictsLight());
|
||||
assertTrue(new EntitySpawns.Attempt(at, zombie, EntitySpawns.Surface.LAND, 8, 15, true).restrictsLight());
|
||||
}
|
||||
|
||||
@Test
|
||||
void answersWithNothingAreEmpty() {
|
||||
assertTrue(BlockDrops.Result.NONE.drops().isEmpty());
|
||||
assertFalse(BlockDrops.Result.NONE.replacesVanillaDrops());
|
||||
assertTrue(SaplingGrowth.TreeObjects.NONE.objects().isEmpty());
|
||||
}
|
||||
|
||||
private static EntitySpec entity(String type, String specialType) {
|
||||
return new EntitySpec(type, specialType, null, "", new EntitySpec.Flags(false, true, true, false, true, false, false,
|
||||
false, false, false, false), EntitySpec.Equipment.NONE, List.of(), List.of(), List.of(), 0L, null, null, false,
|
||||
null, null, false, List.of());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user