Some slight cleanup

This commit is contained in:
Sollace 2020-04-27 18:09:19 +02:00
parent c2a4e66d22
commit f55e6d00b9
8 changed files with 276 additions and 285 deletions

View file

@ -35,6 +35,10 @@ public enum Race {
this.earth = earth; this.earth = earth;
} }
public boolean hasIronGut() {
return isUsable() && this != CHANGELING;
}
public boolean isUsable() { public boolean isUsable() {
return !isDefault(); return !isDefault();
} }

View file

@ -26,123 +26,123 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
public interface UBlocks { public interface UBlocks {
CloudFarmlandBlock CLOUD_FARMLAND = register(new CloudFarmlandBlock(GasState.NORMAL.configure().build()), "cloud_farmland"); CloudFarmlandBlock CLOUD_FARMLAND = register("cloud_farmland", new CloudFarmlandBlock(GasState.NORMAL.configure().build()));
CloudBlock CLOUD_BLOCK = register(new CloudBlock(GasState.NORMAL), "cloud_block"); CloudBlock CLOUD_BLOCK = register("cloud_block", new CloudBlock(GasState.NORMAL));
CloudBlock ENCHANTED_CLOUD_BLOCK = register(new CloudBlock(GasState.ENCHANTED), "enchanted_cloud_block"); CloudBlock ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new CloudBlock(GasState.ENCHANTED));
CloudBlock DENSE_CLOUD_BLOCK = register(new CloudBlock(GasState.DENSE), "dense_cloud_block"); CloudBlock DENSE_CLOUD_BLOCK = register("dense_cloud_block", new CloudBlock(GasState.DENSE));
CloudStairsBlock<CloudBlock> CLOUD_STAIRS = register(new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()), "cloud_stairs"); CloudStairsBlock<CloudBlock> CLOUD_STAIRS = register("cloud_stairs", new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()));
CloudSlabBlock<CloudBlock> CLOUD_SLAB = register(new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()), "cloud_slab"); CloudSlabBlock<CloudBlock> CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()));
CloudSlabBlock<CloudBlock> ENCHANTED_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build()), "enchanted_cloud_slab"); CloudSlabBlock<CloudBlock> ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build()));
CloudSlabBlock<CloudBlock> DENSE_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build()), "dense_cloud_slab"); CloudSlabBlock<CloudBlock> DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build()));
CloudDoorBlock MISTED_GLASS_DOOR = register(new CloudDoorBlock(), "misted_glass_door"); CloudDoorBlock MISTED_GLASS_DOOR = register("misted_glass_door", new CloudDoorBlock());
DutchDoorBlock LIBRARY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD). DutchDoorBlock LIBRARY_DOOR = register("library_door", new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).
sounds(BlockSoundGroup.WOOD) sounds(BlockSoundGroup.WOOD)
.hardness(3) .hardness(3)
.build()), "library_door"); .build()));
DutchDoorBlock BAKERY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD) DutchDoorBlock BAKERY_DOOR = register("bakery_door", new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD)
.sounds(BlockSoundGroup.WOOD) .sounds(BlockSoundGroup.WOOD)
.hardness(3) .hardness(3)
.build()), "bakery_door"); .build()));
DiamondDoorBlock DIAMOND_DOOR = register(new DiamondDoorBlock(), "diamond_door"); DiamondDoorBlock DIAMOND_DOOR = register("diamond_door", new DiamondDoorBlock());
GemTorchBlock ENCHANTED_TORCH = register(new GemTorchBlock(FabricBlockSettings.of(Material.PART) GemTorchBlock ENCHANTED_TORCH = register("enchanted_torch", new GemTorchBlock(FabricBlockSettings.of(Material.PART)
.noCollision() .noCollision()
.breakInstantly() .breakInstantly()
.ticksRandomly() .ticksRandomly()
.lightLevel(1).sounds(BlockSoundGroup.GLASS).build()), "enchanted_torch"); .lightLevel(1).sounds(BlockSoundGroup.GLASS).build()));
GemTorchBlock ENCHANTED_WALL_TORCH = register(new WallGemTorchBlock(FabricBlockSettings.of(Material.PART) GemTorchBlock ENCHANTED_WALL_TORCH = register("enchanted_wall_torch", new WallGemTorchBlock(FabricBlockSettings.of(Material.PART)
.noCollision() .noCollision()
.breakInstantly() .breakInstantly()
.ticksRandomly() .ticksRandomly()
.lightLevel(1).sounds(BlockSoundGroup.GLASS).build()), "enchanted_wall_torch"); .lightLevel(1).sounds(BlockSoundGroup.GLASS).build()));
CloudAnvilBlock CLOUD_ANVIL = register(new CloudAnvilBlock(GasState.NORMAL.configure() CloudAnvilBlock CLOUD_ANVIL = register("cloud_anvil", new CloudAnvilBlock(GasState.NORMAL.configure()
.strength(0.025F, 1) .strength(0.025F, 1)
.resistance(2000) .resistance(2000)
.breakByTool(FabricToolTags.SHOVELS, 0) .breakByTool(FabricToolTags.SHOVELS, 0)
.ticksRandomly() .ticksRandomly()
.build()), "cloud_anvil"); .build()));
CloudFenceBlock CLOUD_FENCE = register(new CloudFenceBlock(GasState.NORMAL), "cloud_fence"); CloudFenceBlock CLOUD_FENCE = register("cloud_fence", new CloudFenceBlock(GasState.NORMAL));
TallCropBlock ALFALFA_CROPS = register(new TallCropBlock(FabricBlockSettings.of(Material.PLANT) TallCropBlock ALFALFA_CROPS = register("alfalfa_crops", new TallCropBlock(FabricBlockSettings.of(Material.PLANT)
.noCollision() .noCollision()
.ticksRandomly() .ticksRandomly()
.breakInstantly() .breakInstantly()
.sounds(BlockSoundGroup.CROP).build()), "alfalfa_crops"); .sounds(BlockSoundGroup.CROP).build()));
StickBlock STICK = register(new StickBlock(FabricBlockSettings.of(Material.WOOD) StickBlock STICK = register("stick", new StickBlock(FabricBlockSettings.of(Material.WOOD)
.noCollision() .noCollision()
.strength(0.2F, 0.2F) .strength(0.2F, 0.2F)
.build()), "stick"); .build()));
TomatoPlantBlock TOMATO_PLANT = register(new TomatoPlantBlock(FabricBlockSettings.of(Material.PLANT) TomatoPlantBlock TOMATO_PLANT = register("tomato_plant", new TomatoPlantBlock(FabricBlockSettings.of(Material.PLANT)
.noCollision() .noCollision()
.strength(0.2F, 0.2F) .strength(0.2F, 0.2F)
.ticksRandomly() .ticksRandomly()
.lightLevel(1) .lightLevel(1)
.sounds(BlockSoundGroup.WOOD) .sounds(BlockSoundGroup.WOOD)
.build()), "tomato_plant"); .build()));
HiveWallBlock HIVE_WALL_BLOCK = register(new HiveWallBlock(FabricBlockSettings.of(UMaterials.HIVE) HiveWallBlock HIVE_WALL_BLOCK = register("hive_wall_block", new HiveWallBlock(FabricBlockSettings.of(UMaterials.HIVE)
.noCollision() .noCollision()
.strength(10, 10) .strength(10, 10)
.hardness(2) .hardness(2)
.ticksRandomly() .ticksRandomly()
.lightLevel(1) .lightLevel(1)
.sounds(BlockSoundGroup.SAND) .sounds(BlockSoundGroup.SAND)
.breakByTool(FabricToolTags.PICKAXES, 1) .breakByTool(FabricToolTags.PICKAXES, 1)
.build()), "hive_wall_block"); .build()));
ChitinBlock CHITIN_SHELL_BLOCK = register(new ChitinBlock(FabricBlockSettings.of(UMaterials.CHITIN) ChitinBlock CHITIN_SHELL_BLOCK = register("chitin_shell_block", new ChitinBlock(FabricBlockSettings.of(UMaterials.CHITIN)
.hardness(50) .hardness(50)
.strength(2000, 2000) .strength(2000, 2000)
.build()), "chitin_shell_block"); .build()));
Block CHISELED_CHITIN_SHELL_BLOCK = register(new ChiselledChitinBlock(FabricBlockSettings.of(UMaterials.CHITIN) Block CHISELED_CHITIN_SHELL_BLOCK = register("chiseled_chitin_shell_block", new ChiselledChitinBlock(FabricBlockSettings.of(UMaterials.CHITIN)
.strength(50, 2000) .strength(50, 2000)
.build()), "chiseled_chitin_shell_block"); .build()));
SlimeDropBlock SLIME_DROP = register(new SlimeDropBlock(FabricBlockSettings.of(UMaterials.HIVE, MaterialColor.GRASS) SlimeDropBlock SLIME_DROP = register("slime_drop", new SlimeDropBlock(FabricBlockSettings.of(UMaterials.HIVE, MaterialColor.GRASS)
.ticksRandomly() .ticksRandomly()
.breakInstantly() .breakInstantly()
.lightLevel(9) .lightLevel(9)
.slipperiness(0.5F) .slipperiness(0.5F)
.sounds(BlockSoundGroup.SLIME) .sounds(BlockSoundGroup.SLIME)
.breakByTool(FabricToolTags.SHOVELS, 2) .breakByTool(FabricToolTags.SHOVELS, 2)
.build()), "slime_drop"); .build()));
SlimeLayerBlock SLIME_LAYER = register(new SlimeLayerBlock(FabricBlockSettings.of(Material.CLAY, MaterialColor.GRASS) SlimeLayerBlock SLIME_LAYER = register("slime_layer", new SlimeLayerBlock(FabricBlockSettings.of(Material.CLAY, MaterialColor.GRASS)
.sounds(BlockSoundGroup.SLIME) .sounds(BlockSoundGroup.SLIME)
.slipperiness(0.8F) .slipperiness(0.8F)
.nonOpaque() .nonOpaque()
.build()), "slime_layer"); .build()));
Block SUGAR_BLOCK = register(new FallingBlock(FabricBlockSettings.of(Material.SAND) Block SUGAR_BLOCK = register("sugar_block", new FallingBlock(FabricBlockSettings.of(Material.SAND)
.strength(10, 10) .strength(10, 10)
.hardness(0.7F) .hardness(0.7F)
.sounds(BlockSoundGroup.SAND) .sounds(BlockSoundGroup.SAND)
.build()), "sugar_block"); .build()));
Block APPLE_LEAVES = register(new FruitLeavesBlock(FabricBlockSettings.of(Material.LEAVES) Block APPLE_LEAVES = register("apple_leaves", new FruitLeavesBlock(FabricBlockSettings.of(Material.LEAVES)
.strength(0.2F, 0.2F) .strength(0.2F, 0.2F)
.ticksRandomly() .ticksRandomly()
.sounds(BlockSoundGroup.GRASS) .sounds(BlockSoundGroup.GRASS)
.build()) .build())
.growthChance(1200) .growthChance(1200)
.tint(0xFFEE81) .tint(0xFFEE81)
.fruit(W -> TreeType.OAK.pickRandomStack()) .fruit(W -> TreeType.OAK.pickRandomStack())
.compost(w -> new ItemStack(UItems.ROTTEN_APPLE)), "apple_leaves"); .compost(w -> new ItemStack(UItems.ROTTEN_APPLE)));
SaplingBlock APPLE_SAPLING = register(new SaplingBlock( SaplingBlock APPLE_SAPLING = register("apple_sapling", new SaplingBlock(
new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), APPLE_LEAVES.getDefaultState()), new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), APPLE_LEAVES.getDefaultState()),
FabricBlockSettings.of(Material.WOOD) FabricBlockSettings.of(Material.WOOD)
.noCollision() .noCollision()
.ticksRandomly() .ticksRandomly()
.breakInstantly() .breakInstantly()
.sounds(BlockSoundGroup.GRASS) .sounds(BlockSoundGroup.GRASS)
.build()) {}, "apple_sapling"); .build()) {});
static <T extends Block> T register(T block, String name) { static <T extends Block> T register(String name, T block) {
return Registry.BLOCK.add(new Identifier("unicopia", name), block); return Registry.BLOCK.add(new Identifier("unicopia", name), block);
} }

View file

@ -30,150 +30,150 @@ import net.minecraft.util.registry.Registry;
public interface UItems { public interface UItems {
AppleItem GREEN_APPLE = register(new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)), "green_apple"); AppleItem GREEN_APPLE = register("green_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
AppleItem SWEET_APPLE = register(new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)), "sweet_apple"); AppleItem SWEET_APPLE = register("sweet_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
AppleItem SOUR_APPLE = register(new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)), "sour_apple"); AppleItem SOUR_APPLE = register("sour_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
ZapAppleItem ZAP_APPLE = register(new ZapAppleItem(new Item.Settings().group(ItemGroup.FOOD).food(UFoodComponents.ZAP_APPLE)), "zap_apple"); ZapAppleItem ZAP_APPLE = register("zap_apple", new ZapAppleItem(new Item.Settings().group(ItemGroup.FOOD).food(UFoodComponents.ZAP_APPLE)));
AppleItem ROTTEN_APPLE = register(new RottenAppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)), "rotten_apple"); AppleItem ROTTEN_APPLE = register("rotten_apple", new RottenAppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
AppleItem COOKED_ZAP_APPLE = register(new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)), "cooked_zap_apple"); AppleItem COOKED_ZAP_APPLE = register("cooked_zap_apple", new AppleItem(new Item.Settings().group(ItemGroup.FOOD).food(FoodComponents.APPLE)));
Item CLOUD_MATTER = register(new Item(new Settings().group(ItemGroup.MATERIALS)), "cloud_matter"); Item CLOUD_MATTER = register("cloud_matter", new Item(new Settings().group(ItemGroup.MATERIALS)));
Item DEW_DROP = register(new Item(new Settings().group(ItemGroup.MATERIALS)), "dew_drop"); Item DEW_DROP = register("dew_drop", new Item(new Settings().group(ItemGroup.MATERIALS)));
CloudPlacerItem RACING_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.RACING_CLOUD), "racing_cloud_spawner"); CloudPlacerItem RACING_CLOUD_SPAWNER = register("racing_cloud_spawner", new CloudPlacerItem(UEntities.RACING_CLOUD));
CloudPlacerItem CONSTRUCTION_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.CONSTRUCTION_CLOUD), "construction_cloud_spawner"); CloudPlacerItem CONSTRUCTION_CLOUD_SPAWNER = register("construction_cloud_spawner", new CloudPlacerItem(UEntities.CONSTRUCTION_CLOUD));
CloudPlacerItem WILD_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.WILD_CLOUD), "wild_cloud_spawner"); CloudPlacerItem WILD_CLOUD_SPAWNER = register("wild_cloud_spawner", new CloudPlacerItem(UEntities.WILD_CLOUD));
Item CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS), "cloud_block"); Item CLOUD_BLOCK = register("cloud_block", new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
Item ENCHANTED_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS), "enchanted_cloud_block"); Item ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
Item DENSE_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS), "dense_cloud_block"); Item DENSE_CLOUD_BLOCK = register("dense_cloud_block", new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
Item CLOUD_STAIRS = register(new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "cloud_stairs"); Item CLOUD_STAIRS = register("cloud_stairs", new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS));
Item CLOUD_FENCE = register(new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS), "cloud_fence"); Item CLOUD_FENCE = register("cloud_fence", new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS));
Item CLOUD_ANVIL = register(new PredicatedBlockItem(UBlocks.CLOUD_ANVIL, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS), "cloud_anvil"); Item CLOUD_ANVIL = register("cloud_anvil", new PredicatedBlockItem(UBlocks.CLOUD_ANVIL, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS));
Item MUSIC_DISC_CRUSADE = register(createRecord(USounds.RECORD_CRUSADE), "music_disc_crusade"); Item MUSIC_DISC_CRUSADE = register("music_disc_crusade", USounds.RECORD_CRUSADE);
Item MUSIC_DISC_PET = register(createRecord(USounds.RECORD_PET), "music_disc_pet"); Item MUSIC_DISC_PET = register("music_disc_pet", USounds.RECORD_PET);
Item MUSIC_DISC_POPULAR = register(createRecord(USounds.RECORD_POPULAR), "music_disc_popular"); Item MUSIC_DISC_POPULAR = register("music_disc_popular", USounds.RECORD_POPULAR);
Item MUSIC_DISC_FUNK = register(createRecord(USounds.RECORD_FUNK), "music_disc_funk"); Item MUSIC_DISC_FUNK = register("music_disc_funk", USounds.RECORD_FUNK);
Item HIVE_WALL_BLOCK = register(new BlockItem(UBlocks.HIVE_WALL_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)), "hive_wall_block"); Item HIVE_WALL_BLOCK = register("hive_wall_block", new BlockItem(UBlocks.HIVE_WALL_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)));
Item CHITIN_SHELL = register(new Item(new Settings().group(ItemGroup.MATERIALS)), "chitin_shell"); Item CHITIN_SHELL = register("chitin_shell", new Item(new Settings().group(ItemGroup.MATERIALS)));
Item CHITIN_SHELL_BLOCK = register(new BlockItem(UBlocks.CHITIN_SHELL_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)), "chitin_shell_block"); Item CHITIN_SHELL_BLOCK = register("chitin_shell_block", new BlockItem(UBlocks.CHITIN_SHELL_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)));
Item CHISELED_CHITIN_SHELL_BLOCK = register(new BlockItem(UBlocks.CHISELED_CHITIN_SHELL_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)), "chiseled_chitin_shell_block"); Item CHISELED_CHITIN_SHELL_BLOCK = register("chiseled_chitin_shell_block", new BlockItem(UBlocks.CHISELED_CHITIN_SHELL_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)));
Item SLIME_DROP = register(new BlockItem(UBlocks.SLIME_DROP, new Settings().group(ItemGroup.MATERIALS)), "slime_drop"); Item SLIME_DROP = register("slime_drop", new BlockItem(UBlocks.SLIME_DROP, new Settings().group(ItemGroup.MATERIALS)));
Item SLIME_LAYER = register(new BlockItem(UBlocks.SLIME_LAYER, new Settings().group(ItemGroup.DECORATIONS)), "slime_layer"); Item SLIME_LAYER = register("slime_layer", new BlockItem(UBlocks.SLIME_LAYER, new Settings().group(ItemGroup.DECORATIONS)));
Item MISTED_GLASS_DOOR = register(new TallBlockItem(UBlocks.MISTED_GLASS_DOOR, new Settings().group(ItemGroup.REDSTONE)), "misted_glass_door"); Item MISTED_GLASS_DOOR = register("misted_glass_door", new TallBlockItem(UBlocks.MISTED_GLASS_DOOR, new Settings().group(ItemGroup.REDSTONE)));
Item LIBRARY_DOOR = register(new TallBlockItem(UBlocks.LIBRARY_DOOR, new Settings().group(ItemGroup.REDSTONE)), "library_door"); Item LIBRARY_DOOR = register("library_door", new TallBlockItem(UBlocks.LIBRARY_DOOR, new Settings().group(ItemGroup.REDSTONE)));
Item BAKERY_DOOR = register(new TallBlockItem(UBlocks.BAKERY_DOOR, new Settings().group(ItemGroup.REDSTONE)), "bakery_door"); Item BAKERY_DOOR = register("bakery_door", new TallBlockItem(UBlocks.BAKERY_DOOR, new Settings().group(ItemGroup.REDSTONE)));
Item DIAMOND_DOOR = register(new TallBlockItem(UBlocks.DIAMOND_DOOR, new Settings().group(ItemGroup.REDSTONE)), "diamond_door"); Item DIAMOND_DOOR = register("diamond_door", new TallBlockItem(UBlocks.DIAMOND_DOOR, new Settings().group(ItemGroup.REDSTONE)));
Item SUGAR_BLOCK = register(new BlockItem(UBlocks.SUGAR_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)), "sugar_block"); Item SUGAR_BLOCK = register("sugar_block", new BlockItem(UBlocks.SUGAR_BLOCK, new Settings().group(ItemGroup.BUILDING_BLOCKS)));
Item CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "cloud_slab"); Item CLOUD_SLAB = register("cloud_slab", new PredicatedBlockItem(UBlocks.CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS));
Item ENCHANTED_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "enchanted_cloud_slab"); Item ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS));
Item DENSE_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS), "dense_cloud_slab"); Item DENSE_CLOUD_SLAB = register("dense_cloud_slab", new PredicatedBlockItem(UBlocks.DENSE_CLOUD_SLAB, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS));
MagicGemItem GEM = register(new MagicGemItem(new Settings().maxCount(16).group(ItemGroup.BREWING)), "gem"); MagicGemItem GEM = register("gem", new MagicGemItem(new Settings().maxCount(16).group(ItemGroup.BREWING)));
MagicGemItem CORRUPTED_GEM = register(new CursedMagicGemItem(new Settings().maxCount(16).group(ItemGroup.BREWING)), "corrupted_gem"); MagicGemItem CORRUPTED_GEM = register("corrupted_gem", new CursedMagicGemItem(new Settings().maxCount(16).group(ItemGroup.BREWING)));
BagOfHoldingItem BAG_OF_HOLDING = register(new BagOfHoldingItem(new Settings().group(ItemGroup.TRANSPORTATION).rarity(Rarity.UNCOMMON).maxCount(1)), "bag_of_holding"); BagOfHoldingItem BAG_OF_HOLDING = register("bag_of_holding", new BagOfHoldingItem(new Settings().group(ItemGroup.TRANSPORTATION).rarity(Rarity.UNCOMMON).maxCount(1)));
AlicornAmuletItem ALICORN_AMULET = register(new AlicornAmuletItem(new Settings().group(ItemGroup.COMBAT).rarity(Rarity.RARE).maxCount(1)), "alicorn_amulet"); AlicornAmuletItem ALICORN_AMULET = register("alicorn_amulet", new AlicornAmuletItem(new Settings().group(ItemGroup.COMBAT).rarity(Rarity.RARE).maxCount(1)));
SpellbookItem SPELLBOOK = register(new SpellbookItem(new Item.Settings().maxCount(1).group(ItemGroup.BREWING)), "spellbook"); SpellbookItem SPELLBOOK = register("spellbook", new SpellbookItem(new Item.Settings().maxCount(1).group(ItemGroup.BREWING)));
Item MEADOW_BROOK_STAFF = register(new StaffItem(new Settings().group(ItemGroup.TOOLS).rarity(Rarity.UNCOMMON).maxCount(1).maxDamage(2)), "meadow_brook_staff"); Item MEADOW_BROOK_STAFF = register("meadow_brook_staff", new StaffItem(new Settings().group(ItemGroup.TOOLS).rarity(Rarity.UNCOMMON).maxCount(1).maxDamage(2)));
Item REMEMBERANCE_STAFF = register(new EnchantedStaffItem(new Settings().group(ItemGroup.TOOLS).rarity(Rarity.UNCOMMON).maxCount(1), new ScorchSpell()), "remembrance_staff"); Item REMEMBERANCE_STAFF = register("remembrance_staff", new EnchantedStaffItem(new Settings().group(ItemGroup.TOOLS).rarity(Rarity.UNCOMMON).maxCount(1), new ScorchSpell()));
Item SPEAR = register(new SpearItem(new Settings().group(ItemGroup.TOOLS).maxCount(1).maxDamage(500)), "spear"); Item SPEAR = register("spear", new SpearItem(new Settings().group(ItemGroup.TOOLS).maxCount(1).maxDamage(500)));
MossItem MOSS = register(new MossItem(new Settings().group(ItemGroup.FOOD).food(UFoodComponents.RANDOM_FOLIAGE)), "moss"); MossItem MOSS = register("moss", new MossItem(new Settings().group(ItemGroup.FOOD).food(UFoodComponents.RANDOM_FOLIAGE)));
Item ALFALFA_SEEDS = register(new AliasedBlockItem(UBlocks.ALFALFA_CROPS, new Settings().group(ItemGroup.MATERIALS).food(UFoodComponents.ALFALFA_SEEDS)), "alfalfa_seeds"); Item ALFALFA_SEEDS = register("alfalfa_seeds", new AliasedBlockItem(UBlocks.ALFALFA_CROPS, new Settings().group(ItemGroup.MATERIALS).food(UFoodComponents.ALFALFA_SEEDS)));
Item ALFALFA_LEAVES = register(new Item(new Settings().group(ItemGroup.FOOD).food(UFoodComponents.ALFALFA_LEAVES)), "alfalfa_leaves"); Item ALFALFA_LEAVES = register("alfalfa_leaves", new Item(new Settings().group(ItemGroup.FOOD).food(UFoodComponents.ALFALFA_LEAVES)));
Item ENCHANTED_TORCH = register(new WallStandingBlockItem(UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH, new Settings().group(ItemGroup.DECORATIONS)), "enchanted_torch"); Item ENCHANTED_TORCH = register("enchanted_torch", new WallStandingBlockItem(UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH, new Settings().group(ItemGroup.DECORATIONS)));
Item CEREAL = register(new SugaryItem(new Settings() Item CEREAL = register("cereal", new SugaryItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.CEREAL) .food(UFoodComponents.CEREAL)
.maxCount(1) .maxCount(1)
.recipeRemainder(Items.BOWL), 1), "cereal"); .recipeRemainder(Items.BOWL), 1));
Item BOOP_O_ROOPS = register(new SugaryItem(new Settings() Item BOOP_O_ROOPS = register("boop_o_roops", new SugaryItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.SUGAR) .food(UFoodComponents.SUGAR)
.maxCount(1) .maxCount(1)
.recipeRemainder(Items.BOWL), 110), "boop_o_roops"); .recipeRemainder(Items.BOWL), 110));
TomatoSeedsItem TOMATO_SEEDS = register(new TomatoSeedsItem(new Settings().group(ItemGroup.MATERIALS)), "tomato_seeds"); TomatoSeedsItem TOMATO_SEEDS = register("tomato_seeds", new TomatoSeedsItem(new Settings().group(ItemGroup.MATERIALS)));
TomatoItem TOMATO = register(new TomatoItem(new Settings() TomatoItem TOMATO = register("tomato", new TomatoItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.TOMATO)), "tomato"); .food(UFoodComponents.TOMATO)));
RottenTomatoItem ROTTEN_TOMATO = register(new RottenTomatoItem(new Settings() RottenTomatoItem ROTTEN_TOMATO = register("rotten_tomato", new RottenTomatoItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.BAD_TOMATO)), "rotten_tomato"); .food(UFoodComponents.BAD_TOMATO)));
TomatoItem CLOUDSDALE_TOMATO = register(new TomatoItem(new Settings() TomatoItem CLOUDSDALE_TOMATO = register("cloudsdale_tomato", new TomatoItem(new Settings()
.rarity(Rarity.UNCOMMON) .rarity(Rarity.UNCOMMON)
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.GOOD_TOMATO)), "cloudsdale_tomato"); .food(UFoodComponents.GOOD_TOMATO)));
RottenTomatoItem ROTTEN_CLOUDSDALE_TOMATO = register(new RottenTomatoItem(new Settings() RottenTomatoItem ROTTEN_CLOUDSDALE_TOMATO = register("rotten_cloudsdale_tomato", new RottenTomatoItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.rarity(Rarity.UNCOMMON) .rarity(Rarity.UNCOMMON)
.food(UFoodComponents.BAD_TOMATO)), "rotten_cloudsdale_tomato"); .food(UFoodComponents.BAD_TOMATO)));
Item APPLE_SEEDS = register(new BlockItem(UBlocks.APPLE_SAPLING, new Settings().group(ItemGroup.DECORATIONS)), "apple_seeds"); Item APPLE_SEEDS = register("apple_seeds", new BlockItem(UBlocks.APPLE_SAPLING, new Settings().group(ItemGroup.DECORATIONS)));
Item APPLE_LEAVES = register(new BlockItem(UBlocks.APPLE_LEAVES, new Settings().group(ItemGroup.DECORATIONS)), "apple_leaves"); Item APPLE_LEAVES = register("apple_leaves", new BlockItem(UBlocks.APPLE_LEAVES, new Settings().group(ItemGroup.DECORATIONS)));
Item DAFFODIL_DAISY_SANDWICH = register(new ToxicItem(new Settings() Item DAFFODIL_DAISY_SANDWICH = register("daffodil_daisy_sandwich", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.DAFODIL_DAISY_SANDWICH), UseAction.EAT, Toxicity::fromStack, Toxin.FOOD), "daffodil_daisy_sandwich"); .food(UFoodComponents.DAFODIL_DAISY_SANDWICH), UseAction.EAT, Toxicity::fromStack, Toxin.FOOD));
Item HAY_BURGER = register(new ToxicItem(new Settings() Item HAY_BURGER = register("hay_burger", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.HAY_BURGER), UseAction.EAT, Toxicity::fromStack, Toxin.FOOD), "hay_burger"); .food(UFoodComponents.HAY_BURGER), UseAction.EAT, Toxicity::fromStack, Toxin.FOOD));
Item HAY_FRIES = register(new ToxicItem(new Settings() Item HAY_FRIES = register("hay_fries", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.HAY_FRIES), UseAction.EAT, Toxicity.SAFE, Toxin.FOOD), "hay_fries"); .food(UFoodComponents.HAY_FRIES), UseAction.EAT, Toxicity.SAFE, Toxin.FOOD));
Item SALAD = register(new ToxicItem(new Settings() Item SALAD = register("salad", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.SALAD) .food(UFoodComponents.SALAD)
.recipeRemainder(Items.BOWL), UseAction.EAT, Toxicity::fromStack, Toxin.FOOD), "salad"); .recipeRemainder(Items.BOWL), UseAction.EAT, Toxicity::fromStack, Toxin.FOOD));
Item WHEAT_WORMS = register(new ToxicItem(new Settings() Item WHEAT_WORMS = register("wheat_worms", new ToxicItem(new Settings()
.group(ItemGroup.MISC) .group(ItemGroup.MISC)
.food(UFoodComponents.WORMS), UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD), "wheat_worms"); .food(UFoodComponents.WORMS), UseAction.EAT, Toxicity.SEVERE, Toxin.FOOD));
Item MUG = register(new Item(new Settings().group(ItemGroup.MATERIALS)), "mug"); Item MUG = register("mug", new Item(new Settings().group(ItemGroup.MATERIALS)));
Item CIDER = register(new ToxicItem(new Settings() Item CIDER = register("apple_cider", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.food(UFoodComponents.SALAD) .food(UFoodComponents.SALAD)
.recipeRemainder(MUG), UseAction.DRINK, Toxicity.MILD, Toxin.FOOD), "apple_cider"); .recipeRemainder(MUG), UseAction.DRINK, Toxicity.MILD, Toxin.FOOD));
Item JUICE = register(new ToxicItem(new Settings() Item JUICE = register("juice", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.recipeRemainder(Items.GLASS_BOTTLE) .recipeRemainder(Items.GLASS_BOTTLE)
.food(UFoodComponents.JUICE), UseAction.DRINK, Toxicity.SAFE, Toxin.FOOD), "juice"); .food(UFoodComponents.JUICE), UseAction.DRINK, Toxicity.SAFE, Toxin.FOOD));
Item BURNED_JUICE = register(new ToxicItem(new Settings() Item BURNED_JUICE = register("burned_juice", new ToxicItem(new Settings()
.group(ItemGroup.FOOD) .group(ItemGroup.FOOD)
.recipeRemainder(Items.GLASS_BOTTLE) .recipeRemainder(Items.GLASS_BOTTLE)
.food(UFoodComponents.BURNED_JUICE), UseAction.DRINK, Toxicity.FAIR, Toxin.FOOD), "burned_juice"); .food(UFoodComponents.BURNED_JUICE), UseAction.DRINK, Toxicity.FAIR, Toxin.FOOD));
Item CLOUD_SPAWN_EGG = register(new SpawnEggItem(UEntities.CLOUD, 0x4169e1, 0x7fff00, new Settings().group(ItemGroup.MISC)), "cloud_spawn_egg"); Item CLOUD_SPAWN_EGG = register("cloud_spawn_egg", new SpawnEggItem(UEntities.CLOUD, 0x4169e1, 0x7fff00, new Settings().group(ItemGroup.MISC)));
Item BUTTERFLY_SPAWN_EGG = register(new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Settings().group(ItemGroup.MISC)), "butterfly_spawn_egg"); Item BUTTERFLY_SPAWN_EGG = register("butterfly_spawn_egg", new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Settings().group(ItemGroup.MISC)));
static <T extends Item> T register(T item, String name) { static <T extends Item> T register(String name, T item) {
if (item instanceof BlockItem) { if (item instanceof BlockItem) {
((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item); ((BlockItem)item).appendBlocks(Item.BLOCK_ITEMS, item);
} }
return Registry.ITEM.add(new Identifier("unicopia", name), item); return Registry.ITEM.add(new Identifier("unicopia", name), item);
} }
static MusicDiscItem createRecord(SoundEvent sound) { static MusicDiscItem register(String name, SoundEvent sound) {
return new MusicDiscItem(1, sound, new Settings() return register(name, new MusicDiscItem(1, sound, new Settings()
.maxCount(1) .maxCount(1)
.group(ItemGroup.MISC) .group(ItemGroup.MISC)
.rarity(Rarity.RARE) .rarity(Rarity.RARE)
) {}; ) {});
} }
static void bootstrap() { static void bootstrap() {

View file

@ -8,15 +8,15 @@ import net.minecraft.util.registry.Registry;
public interface UParticles { public interface UParticles {
ParticleType<MagicParticleEffect> UNICORN_MAGIC = register(FabricParticleTypes.complex(MagicParticleEffect.UNICORN_FACTORY), "unicorn_magic"); ParticleType<MagicParticleEffect> UNICORN_MAGIC = register("unicorn_magic", FabricParticleTypes.complex(MagicParticleEffect.UNICORN_FACTORY));
DefaultParticleType CHANGELING_MAGIC = register(FabricParticleTypes.simple(), "changeling_magic"); DefaultParticleType CHANGELING_MAGIC = register("changeling_magic", FabricParticleTypes.simple());
DefaultParticleType RAIN_DROPS = register(FabricParticleTypes.simple(), "rain_drops"); DefaultParticleType RAIN_DROPS = register("rain_drops", FabricParticleTypes.simple());
DefaultParticleType SPHERE = register(FabricParticleTypes.simple(true), "sphere"); DefaultParticleType SPHERE = register("sphere", FabricParticleTypes.simple(true));
DefaultParticleType DISK = register(FabricParticleTypes.simple(), "disk"); DefaultParticleType DISK = register("disk", FabricParticleTypes.simple());
static <T extends ParticleType<?>> T register(T type, String name) { static <T extends ParticleType<?>> T register(String name, T type) {
return Registry.register(Registry.PARTICLE_TYPE, new Identifier("unicopia", name), type); return Registry.register(Registry.PARTICLE_TYPE, new Identifier("unicopia", name), type);
} }
} }

View file

@ -21,7 +21,7 @@ public interface UStructures {
static <C extends FeatureConfig, F extends Feature<C>> F feature(String id, F feature) { static <C extends FeatureConfig, F extends Feature<C>> F feature(String id, F feature) {
return Registry.register(Registry.FEATURE, new Identifier("unicopia", id), feature); return Registry.register(Registry.FEATURE, new Identifier("unicopia", id), feature);
} }
static void bootstrap() { } static void bootstrap() { }
} }

View file

@ -47,9 +47,9 @@ public class Toxic {
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) { public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
if (entity instanceof PlayerEntity) { if (entity instanceof PlayerEntity) {
Race race = Pony.of((PlayerEntity)entity).getSpecies(); Race race = Pony.of((PlayerEntity)entity).getSpecies();
Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : this.toxicity.apply(stack); Toxicity t = race.hasIronGut() ? toxicity.apply(stack) : Toxicity.LETHAL;
toxin.addSecondaryEffects((PlayerEntity)entity, toxicity, stack); toxin.afflict((PlayerEntity)entity, t, stack);
} }
return new ItemStack(item.getRecipeRemainder()); return new ItemStack(item.getRecipeRemainder());
@ -58,10 +58,10 @@ public class Toxic {
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand, Supplier<TypedActionResult<ItemStack>> sup) { public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand, Supplier<TypedActionResult<ItemStack>> sup) {
Race race = Pony.of(player).getSpecies(); Race race = Pony.of(player).getSpecies();
if (race.isDefault() || race == Race.CHANGELING) { if (race.hasIronGut()) {
return new TypedActionResult<>(ActionResult.FAIL, player.getStackInHand(hand)); return sup.get();
} }
return sup.get(); return new TypedActionResult<>(ActionResult.FAIL, player.getStackInHand(hand));
} }
} }

View file

@ -5,15 +5,18 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.minelittlepony.unicopia.item.UEffects;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
public enum Toxicity { public enum Toxicity implements Toxin {
SAFE(0, 0), SAFE(0, 0),
MILD(1, 160), MILD(1, 160),
FAIR(1, 30), FAIR(1, 30),
@ -23,8 +26,7 @@ public enum Toxicity {
private final int level; private final int level;
private final int duration; private final int duration;
private static final Map<String, Toxicity> REGISTRY; private static final Map<String, Toxicity> REGISTRY = Arrays.stream(values()).collect(Collectors.toMap(Toxicity::name, Function.identity()));
private static final Toxicity[] values = values();
Toxicity(int level, int duration) { Toxicity(int level, int duration) {
this.level = level; this.level = level;
@ -47,10 +49,6 @@ public enum Toxicity {
return this == LETHAL; return this == LETHAL;
} }
public StatusEffectInstance getPoisonEffect() {
return new StatusEffectInstance(isMild() ? StatusEffects.NAUSEA : StatusEffects.POISON, duration, level);
}
public String getTranslationKey() { public String getTranslationKey() {
return String.format("toxicity.%s.name", name().toLowerCase()); return String.format("toxicity.%s.name", name().toLowerCase());
} }
@ -61,6 +59,19 @@ public enum Toxicity {
return text; return text;
} }
@Override
public void afflict(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
if (toxicWhenRaw()) {
player.addStatusEffect(new StatusEffectInstance(isMild() ? StatusEffects.NAUSEA : StatusEffects.POISON, duration, level));
}
if (isLethal()) {
player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false));
} else if (toxicWhenCooked()) {
WEAK_NAUSEA.afflict(player, toxicity, stack);
}
}
public static Toxicity fromStack(ItemStack stack) { public static Toxicity fromStack(ItemStack stack) {
if (stack.hasTag()) { if (stack.hasTag()) {
CompoundTag tag = stack.getSubTag("toxicity"); CompoundTag tag = stack.getSubTag("toxicity");
@ -70,24 +81,4 @@ public enum Toxicity {
} }
return SAFE; return SAFE;
} }
@Deprecated
public static Toxicity byMetadata(int metadata) {
return values[metadata % values.length];
}
@Deprecated
public static String[] getVariants(String key) {
String[] result = new String[values.length];
for (int i = 0; i < result.length; i++) {
result[i] = values[i].name() + key;
}
return result;
}
static {
REGISTRY = Arrays.stream(values()).collect(Collectors.toMap(Toxicity::name, Function.identity()));
}
} }

View file

@ -1,7 +1,6 @@
package com.minelittlepony.unicopia.toxin; package com.minelittlepony.unicopia.toxin;
import com.minelittlepony.unicopia.item.UEffects; import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -9,43 +8,40 @@ import net.minecraft.item.ItemStack;
@FunctionalInterface @FunctionalInterface
public interface Toxin { public interface Toxin {
Toxin DAMAGE = (player, toxicity, stack) -> { Predicate ONE_EVERY_30_TICKS = (player, toxicity, stack) -> player.world.random.nextInt(30) == 0;
if (player.world.random.nextInt(30) == 0) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 1, 1, false, false));
}
};
Toxin RADIOACTIVITY = (player, toxicity, stack) -> {
if (player.world.random.nextInt(30) == 0) {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 10, 1, false, false));
}
};
Toxin NAUSEA = (player, toxicity, stack) -> {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 30, 1, false, false));
};
Toxin STRENGTH = (player, toxicity, stack) -> {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 30, 1, false, false));
};
Toxin BLINDNESS = (player, toxicity, stack) -> {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 30, 1, false, false));
};
Toxin FOOD = (player, toxicity, stack) -> {
if (toxicity.toxicWhenRaw()) {
player.addStatusEffect(toxicity.getPoisonEffect());
}
if (toxicity.isLethal()) { Toxin DAMAGE = ONE_EVERY_30_TICKS.then(of(StatusEffects.INSTANT_DAMAGE, 1, 1));
player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); Toxin RADIOACTIVITY = ONE_EVERY_30_TICKS.then(of(StatusEffects.GLOWING, 10, 1));
} else if (toxicity.toxicWhenCooked()) { Toxin NAUSEA = of(StatusEffects.NAUSEA, 30, 1);
player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); Toxin WEAK_NAUSEA = of(StatusEffects.NAUSEA, 3, 1);
} Toxin STRENGTH = of(StatusEffects.STRENGTH, 30, 1);
}; Toxin BLINDNESS = of(StatusEffects.BLINDNESS, 30, 1);
Toxin FOOD = (player, toxicity, stack) -> toxicity.afflict(player, toxicity, stack);
void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack); void afflict(PlayerEntity player, Toxicity toxicity, ItemStack stack);
default Toxin and(Toxin other) { default Toxin and(Toxin other) {
Toxin self = this;
return (player, toxicity, stack) -> { return (player, toxicity, stack) -> {
other.addSecondaryEffects(player, toxicity, stack); self.afflict(player, toxicity, stack);
this.addSecondaryEffects(player, toxicity, stack); other.afflict(player, toxicity, stack);
}; };
} }
static Toxin of(StatusEffect effect, int duration, int amplifier) {
return (player, toxicity, stack) -> {
player.addStatusEffect(new StatusEffectInstance(effect, duration, amplifier, false, false));
};
}
interface Predicate {
boolean test(PlayerEntity player, Toxicity toxicity, ItemStack stack);
default Toxin then(Toxin toxin) {
return (player, toxicity, stack) -> {
if (test(player, toxicity, stack)) {
toxin.afflict(player, toxicity, stack);
}
};
}
}
} }