mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Merge branch 'wave2/d'
This commit is contained in:
commit
de35bbedb6
17 files changed
+653
-10
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());
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,17 @@ class WorldStateExampleTest {
|
||||
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerLifecycle(this);
|
||||
registry.registerService(ObjectsAt.class, RuinsModule::objectsAt);
|
||||
registry.registerService(ObjectsAt.class, new ObjectsAt() {
|
||||
@Override
|
||||
public Set<String> objectsAt(PackWorld world, int chunkX, int chunkZ) {
|
||||
return RuinsModule.objectsAt(world, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlacedBy placedBy(PackWorld world, String objectKey) {
|
||||
return PlacedBy.NOTHING;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.item.ItemRegistry;
|
||||
import com.volmit.noise.NoiseFactory;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
@@ -28,6 +29,11 @@ public final class EmptyResources implements PackResources {
|
||||
throw new AssertionError("Unused blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRegistry items() {
|
||||
throw new AssertionError("Unused items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoiseFactory noise() {
|
||||
throw new AssertionError("Unused noise");
|
||||
|
||||
Reference in new issue
Block a user