Loot tables and a bunch of other stuff

This commit is contained in:
Sollace 2020-04-22 22:23:47 +02:00
parent 764e2b1efd
commit 46706bc3fb
37 changed files with 525 additions and 194 deletions

View file

@ -18,7 +18,7 @@ public interface JumpingCastle {
* @return An instance of IChannel. * @return An instance of IChannel.
*/ */
static Channel subscribeTo(String channelName, Client clientHandler) { static Channel subscribeTo(String channelName, Client clientHandler) {
return null; return null;// TODO: JumpingFabric
} }
@FunctionalInterface @FunctionalInterface

View file

@ -18,7 +18,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
public final class TreeType { public final class TreeType {
// TODO: Move this to a datapack // TODO: move to datapack
private static final Set<TreeType> REGISTRY = new HashSet<>(); private static final Set<TreeType> REGISTRY = new HashSet<>();
public static final TreeType NONE = new TreeType("none", new Weighted<Supplier<ItemStack>>()); public static final TreeType NONE = new TreeType("none", new Weighted<Supplier<ItemStack>>());

View file

@ -50,7 +50,7 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
@Override @Override
public void apply(Pony player, Hit data) { public void apply(Pony player, Hit data) {
// TODO: A way to pick the active effect // TODO: A way for the player to select which effect they want
if (player.getEffect() instanceof ShieldSpell) { if (player.getEffect() instanceof ShieldSpell) {
player.setEffect(null); player.setEffect(null);
} else { } else {

View file

@ -71,18 +71,6 @@ public class BlockGrowingCuccoon extends Block implements Climbable {
.with(SHAPE, Shape.BULB)); .with(SHAPE, Shape.BULB));
} }
// TODO: loot table
/*
@Override
public int quantityDropped(BlockState state, int fortune, Random random) {
return random.nextInt(3) == 0 ? state.get(AGE) : 0;
}
@Override
public Item getItemDropped(BlockState state, Random rand, int fortune) {
return Items.SLIME_BALL;
}*/
@Override @Override
public boolean isTranslucent(BlockState state, BlockView view, BlockPos pos) { public boolean isTranslucent(BlockState state, BlockView view, BlockPos pos) {
return true; return true;

View file

@ -30,10 +30,6 @@ public class ChitinBlock extends Block {
.build() .build()
); );
setDefaultState(stateManager.getDefaultState().with(COVERING, Covering.UNCOVERED)); setDefaultState(stateManager.getDefaultState().with(COVERING, Covering.UNCOVERED));
// TODO: loot table:
// UItems.chitin_shell x 3
// setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
} }
@Deprecated @Deprecated
@ -55,7 +51,6 @@ public class ChitinBlock extends Block {
return hardness; return hardness;
} }
@Override @Override
@Deprecated @Deprecated
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, IWorld world, BlockPos pos, BlockPos otherPos) { public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState other, IWorld world, BlockPos pos, BlockPos otherPos) {

View file

@ -172,21 +172,6 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
return CloudType.ENCHANTED; return CloudType.ENCHANTED;
} }
// TODO: loot table
/*@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder context) {
Random rand = context.world instanceof World ? ((World)world).random : random;
if (rand.nextInt(10) == 0) {
drops.add(new ItemStack(UItems.spell));
} else {
drops.add(new ItemStack(UItems.curse));
}
return drops;
}*/
@Override @Override
public int getLuminance(BlockState state) { public int getLuminance(BlockState state) {
if (state.get(ON)) { if (state.get(ON)) {

View file

@ -18,8 +18,6 @@ public class SlimeLayerBlock extends SnowBlock {
.materialColor(MaterialColor.GRASS) .materialColor(MaterialColor.GRASS)
.build() .build()
); );
// TODO: drops Items.SLIME_BALL x1
} }
@Override @Override

View file

@ -39,8 +39,6 @@ public class StickBlock extends Block {
.sounds(BlockSoundGroup.WOOD) .sounds(BlockSoundGroup.WOOD)
.build() .build()
); );
// TODO: loot table Items.STICK x1
} }
@Deprecated @Deprecated

View file

@ -13,6 +13,5 @@ public class SugarBlock extends FallingBlock {
.sounds(BlockSoundGroup.SAND) .sounds(BlockSoundGroup.SAND)
.build() .build()
); );
//TODO: loot table SUGAR x 9;
} }
} }

View file

@ -1,7 +1,5 @@
package com.minelittlepony.unicopia.block; package com.minelittlepony.unicopia.block;
import java.util.List;
import com.minelittlepony.unicopia.gas.CloudFarmlandBlock; import com.minelittlepony.unicopia.gas.CloudFarmlandBlock;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
@ -14,8 +12,6 @@ import net.minecraft.entity.EntityContext;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.loot.context.LootContext;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
@ -45,9 +41,6 @@ public class TomatoPlantBlock extends CropBlock {
.build() .build()
); );
setDefaultState(getDefaultState().with(TYPE, Type.NORMAL)); setDefaultState(getDefaultState().with(TYPE, Type.NORMAL));
// TODO: loot table UItems.tomato_seeds x1
// if mature: UItems.tomato
} }
@Override @Override
@ -90,22 +83,6 @@ public class TomatoPlantBlock extends CropBlock {
|| state.getBlock() == UBlocks.stick; || state.getBlock() == UBlocks.stick;
} }
@Override
@Deprecated
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder context) {
List<ItemStack> drops = super.getDroppedStacks(state, context);
drops.add(new ItemStack(Items.STICK, 1));
if (isMature(state)) {
drops.add(new ItemStack(state.get(TYPE).getCrop(), 1));
} else {
drops.add(new ItemStack(getSeedsItem()));
}
return drops;
}
@Override @Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {

View file

@ -53,7 +53,7 @@ public interface UBlocks {
CloudFarmlandBlock cloud_farmland = register(new CloudFarmlandBlock(FabricBlockSettings.of(UMaterials.CLOUD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.WOOL).build()), "cloud_farmland"); CloudFarmlandBlock cloud_farmland = register(new CloudFarmlandBlock(FabricBlockSettings.of(UMaterials.CLOUD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.WOOL).build()), "cloud_farmland");
HiveWallBlock hive = register(new HiveWallBlock(), "hive"); HiveWallBlock hive = register(new HiveWallBlock(), "hive");
ChitinBlock chitin = register(new ChitinBlock(), "chitin_block"); ChitinBlock chitin_block = register(new ChitinBlock(), "chitin_block");
Block chissled_chitin = register(new ChiselledChitinBlock(), "chissled_chitin"); Block chissled_chitin = register(new ChiselledChitinBlock(), "chissled_chitin");
BlockGrowingCuccoon cuccoon = register(new BlockGrowingCuccoon(), "cuccoon"); BlockGrowingCuccoon cuccoon = register(new BlockGrowingCuccoon(), "cuccoon");

View file

@ -0,0 +1,27 @@
package com.minelittlepony.unicopia.blockstate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
public interface BlockStateConverter {
/**
* Checks if this collection contains a mapping capable of converting the given state.
*
* @param state State to check
*
* @return True if the state can be converted
*/
boolean canConvert(@Nullable BlockState state);
/**
* Attempts to convert the given state based on the known mappings in this collection.
*
* @param state State to convert
*
* @return The converted state if there is one, otherwise null
*/
@Nonnull
BlockState getConverted(@Nonnull BlockState state);
}

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.collection; package com.minelittlepony.unicopia.blockstate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.function.Predicate; import java.util.function.Predicate;
@ -14,7 +14,7 @@ import net.minecraft.state.property.Property;
* A collection of block-state mappings. * A collection of block-state mappings.
* *
*/ */
public class BlockStateMap extends ArrayList<StateMapping> { class BlockStateMap extends ArrayList<StateMapping> implements BlockStateConverter {
private static final long serialVersionUID = 2602772651960588745L; private static final long serialVersionUID = 2602772651960588745L;
public void removeBlock(Predicate<BlockState> mapper) { public void removeBlock(Predicate<BlockState> mapper) {
@ -33,24 +33,12 @@ public class BlockStateMap extends ArrayList<StateMapping> {
add(StateMapping.setProperty(block, property, to)); add(StateMapping.setProperty(block, property, to));
} }
/** @Override
* Checks if this collection contains a mapping capable of converting the given state.
*
* @param state State to check
*
* @return True if the state can be converted
*/
public boolean canConvert(@Nullable BlockState state) { public boolean canConvert(@Nullable BlockState state) {
return state != null && stream().anyMatch(i -> i.test(state)); return state != null && stream().anyMatch(i -> i.test(state));
} }
/** @Override
* Attempts to convert the given state based on the known mappings in this collection.
*
* @param state State to convert
*
* @return The converted state if there is one, otherwise null
*/
@Nonnull @Nonnull
public BlockState getConverted(@Nonnull BlockState state) { public BlockState getConverted(@Nonnull BlockState state) {
for (StateMapping i : this) { for (StateMapping i : this) {

View file

@ -0,0 +1,5 @@
package com.minelittlepony.unicopia.blockstate;
public interface ReversableBlockStateConverter extends BlockStateConverter {
BlockStateConverter getInverse();
}

View file

@ -1,14 +1,16 @@
package com.minelittlepony.unicopia.util.collection; package com.minelittlepony.unicopia.blockstate;
public class ReversableBlockStateMap extends BlockStateMap { class ReversableBlockStateMap extends BlockStateMap implements ReversableBlockStateConverter {
private static final long serialVersionUID = 6154365988455383098L; private static final long serialVersionUID = 6154365988455383098L;
private final BlockStateMap inverse = new BlockStateMap(); private final BlockStateMap inverse = new BlockStateMap();
@Override
public BlockStateMap getInverse() { public BlockStateMap getInverse() {
return inverse; return inverse;
} }
@Override
public boolean add(StateMapping mapping) { public boolean add(StateMapping mapping) {
inverse.add(mapping.inverse()); inverse.add(mapping.inverse());
return super.add(mapping); return super.add(mapping);

View file

@ -1,4 +1,4 @@
package com.minelittlepony.unicopia.util.collection; package com.minelittlepony.unicopia.blockstate;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
@ -10,7 +10,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
public interface StateMapping extends Predicate<BlockState>, Function<BlockState, BlockState> { interface StateMapping extends Predicate<BlockState>, Function<BlockState, BlockState> {
static StateMapping removeBlock(Predicate<BlockState> mapper) { static StateMapping removeBlock(Predicate<BlockState> mapper) {
return build( return build(

View file

@ -0,0 +1,83 @@
package com.minelittlepony.unicopia.blockstate;
import net.minecraft.block.Blocks;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.Material;
import net.minecraft.block.OreBlock;
import net.minecraft.block.PlantBlock;
import net.minecraft.block.RedstoneWireBlock;
import net.minecraft.block.SnowBlock;
import net.minecraft.util.Util;
public class StateMaps {
public static final BlockStateConverter ICE_AFFECTED = register(Util.make(new BlockStateMap(), a -> {
a.add(StateMapping.build(
s -> s.getMaterial() == Material.WATER,
s -> Blocks.ICE.getDefaultState()));
a.add(StateMapping.build(
s -> s.getMaterial() == Material.LAVA,
s -> Blocks.OBSIDIAN.getDefaultState()));
a.add(StateMapping.build(
s -> s.getBlock() == Blocks.SNOW,
s -> {
s = s.cycle(SnowBlock.LAYERS);
if (s.get(SnowBlock.LAYERS) >= 7) {
return Blocks.SNOW.getDefaultState();
}
return s;
}));
a.replaceBlock(Blocks.FIRE, Blocks.AIR);
a.setProperty(Blocks.REDSTONE_WIRE, RedstoneWireBlock.POWER, 0);
}), "ice");
public static final ReversableBlockStateConverter MOSS_AFFECTED = register(Util.make(new ReversableBlockStateMap(), a -> {
a.replaceBlock(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.COBBLESTONE_SLAB);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_STAIRS, Blocks.COBBLESTONE_STAIRS);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_WALL, Blocks.COBBLESTONE_WALL);
a.replaceBlock(Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.STONE_BRICK_SLAB);
a.replaceBlock(Blocks.MOSSY_STONE_BRICK_STAIRS, Blocks.STONE_BRICK_STAIRS);
a.replaceBlock(Blocks.MOSSY_STONE_BRICK_WALL, Blocks.MOSSY_STONE_BRICK_WALL);
a.replaceBlock(Blocks.MOSSY_STONE_BRICKS, Blocks.STONE_BRICKS);
a.replaceBlock(Blocks.INFESTED_MOSSY_STONE_BRICKS, Blocks.INFESTED_STONE_BRICKS);
}), "moss");
public static final BlockStateConverter FIRE_AFFECTED = register(Util.make(new BlockStateMap(), a -> {
a.removeBlock(s -> s.getBlock() == Blocks.SNOW || s.getBlock() == Blocks.SNOW_BLOCK);
a.removeBlock(s -> s.getBlock() instanceof PlantBlock);
a.replaceBlock(Blocks.CLAY, Blocks.BROWN_CONCRETE);
a.replaceBlock(Blocks.OBSIDIAN, Blocks.LAVA);
a.replaceBlock(Blocks.GRASS, Blocks.DIRT);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_WALL, Blocks.COBBLESTONE_WALL);
a.replaceBlock(Blocks.MOSSY_STONE_BRICKS, Blocks.STONE_BRICKS);
a.replaceBlock(Blocks.INFESTED_MOSSY_STONE_BRICKS, Blocks.INFESTED_STONE_BRICKS);
a.replaceBlock(Blocks.PODZOL, Blocks.COARSE_DIRT);
a.setProperty(Blocks.FARMLAND, FarmlandBlock.MOISTURE, 0);
a.add(StateMapping.build(
s -> s.getBlock() == Blocks.DIRT,
s -> (Math.random() <= 0.15 ? Blocks.COARSE_DIRT.getDefaultState() : s)));
}), "fire");
public static final BlockStateConverter HELLFIRE_AFFECTED = register(Util.make(new BlockStateMap(), a -> {
a.add(StateMapping.build(
s -> s.getBlock() == Blocks.GRASS || s.getBlock() == Blocks.DIRT || s.getBlock() == Blocks.STONE,
s -> Blocks.NETHERRACK.getDefaultState()));
a.replaceBlock(Blocks.SAND, Blocks.SOUL_SAND);
a.replaceBlock(Blocks.GRAVEL, Blocks.SOUL_SAND);
a.add(StateMapping.build(
s -> s.getMaterial() == Material.WATER,
s -> Blocks.OBSIDIAN.getDefaultState()));
a.add(StateMapping.build(
s -> s.getBlock() instanceof PlantBlock,
s -> Blocks.NETHER_WART.getDefaultState()));
a.add(StateMapping.build(
s -> (s.getBlock() != Blocks.NETHER_QUARTZ_ORE) && (s.getBlock() instanceof OreBlock),
s -> Blocks.NETHER_QUARTZ_ORE.getDefaultState()));
}), "hellfire");
private static <T extends BlockStateConverter> T register(T value, String name) {
return value;
}
}

View file

@ -17,10 +17,8 @@ import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
// TODO: need to register this
public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "empty_slot_gem"); public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "empty_slot_gem");
private final Pony player; private final Pony player;
private final SpellBookInventory craftMatrix; private final SpellBookInventory craftMatrix;

View file

@ -33,12 +33,6 @@ public class SpecialRecipe extends AbstractSpecialRecipe {
return output.getStack(); return output.getStack();
} }
@Override
public Identifier getId() {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public RecipeSerializer<?> getSerializer() { public RecipeSerializer<?> getSerializer() {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -75,7 +75,6 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
super(type, world); super(type, world);
ignoreCameraFrustum = true; ignoreCameraFrustum = true;
targetAltitude = getRandomFlyingHeight(); targetAltitude = getRandomFlyingHeight();
// TODO: drops cloud_matter x1
} }
@Override @Override

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.gas;
import java.util.Random; import java.util.Random;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.MossItem;
import com.minelittlepony.unicopia.util.HoeUtil; import com.minelittlepony.unicopia.util.HoeUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -42,7 +42,7 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2)); pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2));
state = world.getBlockState(pos); state = world.getBlockState(pos);
BlockState converted = MossItem.AFFECTED.getInverse().getConverted(state); BlockState converted = StateMaps.MOSS_AFFECTED.getInverse().getConverted(state);
if (!state.equals(converted)) { if (!state.equals(converted)) {
world.setBlockState(pos, converted); world.setBlockState(pos, converted);

View file

@ -2,45 +2,30 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.toxin.ToxicItem; import com.minelittlepony.unicopia.toxin.ToxicItem;
import com.minelittlepony.unicopia.toxin.Toxicity; import com.minelittlepony.unicopia.toxin.Toxicity;
import com.minelittlepony.unicopia.util.collection.ReversableBlockStateMap;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.UseAction; import net.minecraft.util.UseAction;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
public class MossItem extends ToxicItem { public class MossItem extends ToxicItem {
public static final ReversableBlockStateMap AFFECTED = Util.make(new ReversableBlockStateMap(), a -> {
// TODO: move to resourcepack
a.replaceBlock(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.COBBLESTONE_SLAB);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_STAIRS, Blocks.COBBLESTONE_STAIRS);
a.replaceBlock(Blocks.MOSSY_COBBLESTONE_WALL, Blocks.COBBLESTONE_WALL);
a.replaceBlock(Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.STONE_BRICK_SLAB);
a.replaceBlock(Blocks.MOSSY_STONE_BRICK_STAIRS, Blocks.STONE_BRICK_STAIRS);
a.replaceBlock(Blocks.MOSSY_STONE_BRICK_WALL, Blocks.MOSSY_STONE_BRICK_WALL);
a.replaceBlock(Blocks.MOSSY_STONE_BRICKS, Blocks.STONE_BRICKS);
a.replaceBlock(Blocks.INFESTED_MOSSY_STONE_BRICKS, Blocks.INFESTED_STONE_BRICKS);
});
public MossItem(Item.Settings settings) { public MossItem(Item.Settings settings) {
super(settings, 2, 1, UseAction.EAT, Toxicity.FAIR); super(settings, 2, 1, UseAction.EAT, Toxicity.FAIR);
} }
public boolean tryConvert(World world, BlockState state, BlockPos pos, @Nullable PlayerEntity player) { public boolean tryConvert(World world, BlockState state, BlockPos pos, @Nullable PlayerEntity player) {
BlockState converted = AFFECTED.getConverted(state); BlockState converted = StateMaps.MOSS_AFFECTED.getConverted(state);
if (!state.equals(converted)) { if (!state.equals(converted)) {
world.setBlockState(pos, converted, 3); world.setBlockState(pos, converted, 3);

View file

@ -63,7 +63,7 @@ public interface UItems {
Item hive = register(new BlockItem(UBlocks.hive, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "hive"); Item hive = register(new BlockItem(UBlocks.hive, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "hive");
Item chitin_shell = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "chitin_shell"); Item chitin_shell = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "chitin_shell");
Item chitin = register(new BlockItem(UBlocks.chitin, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chitin_block"); Item chitin = register(new BlockItem(UBlocks.chitin_block, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chitin_block");
Item chissled_chitin = register(new BlockItem(UBlocks.chissled_chitin, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chissled_chitin"); Item chissled_chitin = register(new BlockItem(UBlocks.chissled_chitin, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chissled_chitin");
Item cuccoon = register(new BlockItem(UBlocks.cuccoon, new Item.Settings().group(ItemGroup.MATERIALS)), "cuccoon"); Item cuccoon = register(new BlockItem(UBlocks.cuccoon, new Item.Settings().group(ItemGroup.MATERIALS)), "cuccoon");
Item slime_layer = register(new BlockItem(UBlocks.slime_layer, new Item.Settings().group(ItemGroup.DECORATIONS)), "slime_layer"); Item slime_layer = register(new BlockItem(UBlocks.slime_layer, new Item.Settings().group(ItemGroup.DECORATIONS)), "slime_layer");

View file

@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.entity.IMagicals; import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
@ -12,17 +13,13 @@ import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.collection.StateMapping;
import com.minelittlepony.unicopia.util.collection.BlockStateMap;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.PlantBlock;
import net.minecraft.block.RedstoneWireBlock; import net.minecraft.block.RedstoneWireBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ItemEntity;
@ -43,26 +40,11 @@ import net.minecraft.world.World;
public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, DispenceableMagicEffect { public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable, DispenceableMagicEffect {
public final BlockStateMap affected = new BlockStateMap();
private static final Shape visual_effect_region = new Sphere(false, 0.5); private static final Shape visual_effect_region = new Sphere(false, 0.5);
private static final Shape effect_range = new Sphere(false, 4); private static final Shape effect_range = new Sphere(false, 4);
public FireSpell() { public FireSpell() {
affected.removeBlock(s -> s.getBlock() == Blocks.SNOW || s.getBlock() == Blocks.SNOW_BLOCK);
affected.removeBlock(s -> s.getBlock() instanceof PlantBlock);
affected.replaceBlock(Blocks.CLAY, Blocks.BROWN_CONCRETE);
affected.replaceBlock(Blocks.OBSIDIAN, Blocks.LAVA);
affected.replaceBlock(Blocks.GRASS, Blocks.DIRT);
affected.replaceBlock(Blocks.MOSSY_COBBLESTONE, Blocks.COBBLESTONE);
affected.replaceBlock(Blocks.MOSSY_COBBLESTONE_WALL, Blocks.COBBLESTONE_WALL);
affected.replaceBlock(Blocks.MOSSY_STONE_BRICKS, Blocks.STONE_BRICKS);
affected.replaceBlock(Blocks.INFESTED_MOSSY_STONE_BRICKS, Blocks.INFESTED_STONE_BRICKS);
affected.replaceBlock(Blocks.PODZOL, Blocks.COARSE_DIRT);
affected.setProperty(Blocks.FARMLAND, FarmlandBlock.MOISTURE, 0);
affected.add(StateMapping.build(
s -> s.getBlock() == Blocks.DIRT,
s -> (Math.random() <= 0.15 ? Blocks.COARSE_DIRT.getDefaultState() : s)));
} }
@Override @Override
@ -182,7 +164,7 @@ public class FireSpell extends AbstractSpell.RangedAreaSpell implements Useable,
return true; return true;
} }
} else { } else {
BlockState newState = affected.getConverted(state); BlockState newState = StateMaps.FIRE_AFFECTED.getConverted(state);
if (!state.equals(newState)) { if (!state.equals(newState)) {
world.setBlockState(pos, newState, 3); world.setBlockState(pos, newState, 3);

View file

@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.block.UMaterials; import com.minelittlepony.unicopia.block.UMaterials;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
@ -11,8 +12,6 @@ import com.minelittlepony.unicopia.magic.Useable;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.collection.StateMapping;
import com.minelittlepony.unicopia.util.collection.BlockStateMap;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
@ -21,8 +20,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.PlantBlock; import net.minecraft.block.PlantBlock;
import net.minecraft.block.RedstoneWireBlock;
import net.minecraft.block.SnowBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.TntEntity; import net.minecraft.entity.TntEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -37,29 +34,6 @@ import net.minecraft.world.World;
public class IceSpell extends AbstractSpell.RangedAreaSpell implements Useable, DispenceableMagicEffect { public class IceSpell extends AbstractSpell.RangedAreaSpell implements Useable, DispenceableMagicEffect {
public final BlockStateMap affected = new BlockStateMap();
public IceSpell() {
affected.add(StateMapping.build(
s -> s.getMaterial() == Material.WATER,
s -> Blocks.ICE.getDefaultState()));
affected.add(StateMapping.build(
s -> s.getMaterial() == Material.LAVA,
s -> Blocks.OBSIDIAN.getDefaultState()));
affected.add(StateMapping.build(
s -> s.getBlock() == Blocks.SNOW,
s -> {
s = s.cycle(SnowBlock.LAYERS);
if (s.get(SnowBlock.LAYERS) >= 7) {
return Blocks.SNOW.getDefaultState();
}
return s;
}));
affected.replaceBlock(Blocks.FIRE, Blocks.AIR);
affected.setProperty(Blocks.REDSTONE_WIRE, RedstoneWireBlock.POWER, 0);
}
private final int rad = 3; private final int rad = 3;
private final Shape effect_range = new Sphere(false, rad); private final Shape effect_range = new Sphere(false, rad);
@ -144,7 +118,7 @@ public class IceSpell extends AbstractSpell.RangedAreaSpell implements Useable,
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
Block id = state.getBlock(); Block id = state.getBlock();
BlockState converted = affected.getConverted(state); BlockState converted = StateMaps.ICE_AFFECTED.getConverted(state);
if (!state.equals(converted)) { if (!state.equals(converted)) {
world.setBlockState(pos, converted, 3); world.setBlockState(pos, converted, 3);

View file

@ -1,19 +1,14 @@
package com.minelittlepony.unicopia.magic.spell; package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.CastResult;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.collection.StateMapping;
import com.minelittlepony.unicopia.util.collection.BlockStateMap;
import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.OreBlock;
import net.minecraft.block.PlantBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
@ -23,30 +18,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
public class InfernoSpell extends FireSpell { public class InfernoSpell extends FireSpell {
public final BlockStateMap hellFireAffected = new BlockStateMap();
public InfernoSpell() {
hellFireAffected.add(StateMapping.build(
s -> s.getBlock() == Blocks.GRASS || s.getBlock() == Blocks.DIRT || s.getBlock() == Blocks.STONE,
s -> Blocks.NETHERRACK.getDefaultState()));
hellFireAffected.replaceBlock(Blocks.SAND, Blocks.SOUL_SAND);
hellFireAffected.replaceBlock(Blocks.GRAVEL, Blocks.SOUL_SAND);
hellFireAffected.add(StateMapping.build(
s -> s.getMaterial() == Material.WATER,
s -> Blocks.OBSIDIAN.getDefaultState()));
hellFireAffected.add(StateMapping.build(
s -> s.getBlock() instanceof PlantBlock,
s -> Blocks.NETHER_WART.getDefaultState()));
hellFireAffected.add(StateMapping.build(
s -> (s.getBlock() != Blocks.NETHER_QUARTZ_ORE) && (s.getBlock() instanceof OreBlock),
s -> Blocks.NETHER_QUARTZ_ORE.getDefaultState()));
}
@Override @Override
public String getName() { public String getName() {
return "inferno"; return "inferno";
@ -81,7 +52,7 @@ public class InfernoSpell extends FireSpell {
BlockPos pos = new BlockPos(shape.computePoint(w.random).add(origin)); BlockPos pos = new BlockPos(shape.computePoint(w.random).add(origin));
BlockState state = w.getBlockState(pos); BlockState state = w.getBlockState(pos);
BlockState newState = hellFireAffected.getConverted(state); BlockState newState = StateMaps.HELLFIRE_AFFECTED.getConverted(state);
if (!state.equals(newState)) { if (!state.equals(newState)) {
w.setBlockState(pos, newState, 3); w.setBlockState(pos, newState, 3);

View file

@ -2,6 +2,7 @@ package com.minelittlepony.unicopia.magic.spell;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.blockstate.StateMaps;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.magic.TossedMagicEffect; import com.minelittlepony.unicopia.magic.TossedMagicEffect;
@ -40,7 +41,7 @@ public class ScorchSpell extends FireSpell implements TossedMagicEffect {
BlockState state = source.getWorld().getBlockState(pos); BlockState state = source.getWorld().getBlockState(pos);
BlockState newState = affected.getConverted(state); BlockState newState = StateMaps.FIRE_AFFECTED.getConverted(state);
if (!state.equals(newState)) { if (!state.equals(newState)) {
source.getWorld().setBlockState(pos, newState, 3); source.getWorld().setBlockState(pos, newState, 3);

View file

@ -0,0 +1,38 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:chitin_shell",
"functions": [
{
"function": "minecraft:set_count",
"count": 3
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {
"bonusMultiplier": 1
}
},
{
"function": "minecraft:limit_count",
"limit": {
"max": 3,
"min": 1
}
},
{
"function": "minecraft:explosion_decay"
}
]
}
]
}
]
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:slime_ball",
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 3,
"max": 5
}
}
]
}
]
}
]
}

View file

@ -0,0 +1,18 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:spell"
},
{
"type": "minecraft:item",
"name": "unicopia:curse"
}
]
}
]
}

View file

@ -0,0 +1,23 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:slime_ball",
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 3,
"max": 5
}
}
]
}
]
}
]
}

View file

@ -0,0 +1,11 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{ "type": "minecraft:item", "name": "minecraft:stick" }
]
}
]
}

View file

@ -0,0 +1,38 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:sugar",
"functions": [
{
"function": "minecraft:set_count",
"count": 4
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {
"bonusMultiplier": 1
}
},
{
"function": "minecraft:limit_count",
"limit": {
"max": 6,
"min": 1
}
},
{
"function": "minecraft:explosion_decay"
}
]
}
]
}
]
}

View file

@ -0,0 +1,138 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:stick"
}
]
},
{
"rolls": 1.0,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"name": "unicopia:tomato",
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant",
"properties": {
"age": "7",
"type": "normal"
}
}
],
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 1,
"max": 5
}
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {
"bonusMultiplier": 1
}
},
{
"function": "minecraft:limit_count",
"limit": {
"max": 9,
"min": 1
}
}
]
},
{
"type": "minecraft:item",
"name": "unicopia:cloudsdale_tomato",
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant",
"properties": {
"age": "7",
"type": "cloudsdale"
}
}
],
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 1,
"max": 5
}
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {
"bonusMultiplier": 1
}
},
{
"function": "minecraft:limit_count",
"limit": {
"max": 9,
"min": 1
}
}
]
},
{
"type": "minecraft:item",
"name": "minecraft:tomato_seeds"
}
]
}
]
},
{
"rolls": 1.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:binomial_with_bonus_count",
"parameters": {
"extra": 3,
"probability": 0.5714286
}
}
],
"name": "unicopia:tomato_seeds"
}
],
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant",
"properties": {
"age": "7"
}
}
]
}
],
"functions": [
{
"function": "minecraft:explosion_decay"
}
]
}

View file

@ -0,0 +1,31 @@
{
"type": "minecraft:entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 2,
"max": 5,
"type": "minecraft:uniform"
}
},
{
"function": "minecraft:looting_enchant",
"count": {
"min": 0,
"max": 6
}
}
],
"name": "unicopia:cloud_matter"
}
]
}
]
}

View file

@ -0,0 +1,31 @@
{
"type": "minecraft:entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 0.0,
"max": 2.0,
"type": "minecraft:uniform"
}
},
{
"function": "minecraft:looting_enchant",
"count": {
"min": 0.0,
"max": 1.0
}
}
],
"name": "unicopia:cloud_matter"
}
]
}
]
}

View file

@ -0,0 +1,31 @@
{
"type": "minecraft:entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 0.0,
"max": 2.0,
"type": "minecraft:uniform"
}
},
{
"function": "minecraft:looting_enchant",
"count": {
"min": 0.0,
"max": 1.0
}
}
],
"name": "unicopia:cloud_matter"
}
]
}
]
}