Fix naming conventions

This commit is contained in:
Sollace 2020-04-24 15:23:36 +02:00
parent 5f1487d725
commit 167f67c5fb
30 changed files with 238 additions and 248 deletions

View file

@ -12,29 +12,29 @@ import net.minecraft.world.World;
public class AwaitTickQueue {
private static final Queue<Consumer<World>> tickTasks = Queues.newArrayDeque();
private static List<DelayedTask> delayedTasks = Lists.newArrayList();
private static final Queue<Consumer<World>> SCHEDULED_TASKS = Queues.newArrayDeque();
private static List<DelayedTask> DELAYED_TASKS = Lists.newArrayList();
private static final Object locker = new Object();
private static final Object LOCKER = new Object();
public static void enqueueTask(Consumer<World> task) {
synchronized (locker) {
tickTasks.add(task);
synchronized (LOCKER) {
SCHEDULED_TASKS.add(task);
}
}
public static void scheduleTask(Consumer<World> task, int ticksLater) {
synchronized (locker) {
delayedTasks.add(new DelayedTask(task, ticksLater));
synchronized (LOCKER) {
DELAYED_TASKS.add(new DelayedTask(task, ticksLater));
}
}
public void tick(World world) {
synchronized (locker) {
delayedTasks = delayedTasks.stream().filter(DelayedTask::tick).collect(Collectors.toList());
synchronized (LOCKER) {
DELAYED_TASKS = DELAYED_TASKS.stream().filter(DelayedTask::tick).collect(Collectors.toList());
Consumer<World> task;
while ((task = tickTasks.poll()) != null) {
while ((task = SCHEDULED_TASKS.poll()) != null) {
try {
task.accept(world);
} catch (Exception e) {
@ -56,7 +56,7 @@ public class AwaitTickQueue {
boolean tick() {
if (ticksDelay-- <= 0) {
tickTasks.add(task);
SCHEDULED_TASKS.add(task);
return false;
}

View file

@ -14,15 +14,15 @@ import com.google.gson.stream.JsonWriter;
public class Config {
private static Config instance = new Config();
private static Config INSTANCE = new Config();
private static final Gson gson = new GsonBuilder()
private static final Gson GSON = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.setPrettyPrinting()
.create();
public static Config getInstance() {
return instance;
return INSTANCE;
}
static void init(Path directory) {
@ -31,19 +31,19 @@ public class Config {
try {
if (Files.exists(file)) {
try(JsonReader reader = new JsonReader(Files.newBufferedReader(file))) {
instance = gson.fromJson(reader, Config.class);
INSTANCE = GSON.fromJson(reader, Config.class);
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (instance == null) {
instance = new Config();
if (INSTANCE == null) {
INSTANCE = new Config();
}
}
instance.file = file;
instance.save();
INSTANCE.file = file;
INSTANCE.save();
}
private Path file;
@ -111,7 +111,7 @@ public class Config {
try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(file))) {
writer.setIndent(" ");
gson.toJson(this, Config.class, writer);
GSON.toJson(this, Config.class, writer);
} catch (IOException e) {
e.printStackTrace();
}

View file

@ -26,19 +26,19 @@ public class CustomDrops {
if (world.random.nextInt(500 / fortuneFactor) == 0) {
for (int i = 0; i < 1 + fortune; i++) {
if (world.random.nextInt(10) > 3) {
drops.add(new ItemStack(UItems.curse));
drops.add(new ItemStack(UItems.CORRUPTED_GEM));
} else {
drops.add(new ItemStack(UItems.spell));
drops.add(new ItemStack(UItems.GEM));
}
}
}
if (world.random.nextInt(5000) == 0) {
drops.add(SpellRegistry.instance().enchantStack(new ItemStack(UItems.spell), "awkward"));
drops.add(SpellRegistry.instance().enchantStack(new ItemStack(UItems.GEM), "awkward"));
}
} else if (block == Blocks.DIRT || block == Blocks.CLAY || block == Blocks.GRASS_PATH || block == Blocks.GRASS || block == UBlocks.hive) {
} else if (block == Blocks.DIRT || block == Blocks.CLAY || block == Blocks.GRASS_PATH || block == Blocks.GRASS || block == UBlocks.HIVE_WALL_BLOCK) {
if (world.random.nextInt(25 / fortuneFactor) == 0) {
drops.add(new ItemStack(UItems.wheat_worms, 1 + fortune));
drops.add(new ItemStack(UItems.WHEAT_WORMS, 1 + fortune));
}
} else if (block instanceof GrassBlock) {
if (world.random.nextInt(25 / fortuneFactor) == 0) {
@ -46,11 +46,11 @@ public class CustomDrops {
int chance = world.random.nextInt(3);
if (chance == 0) {
drops.add(new ItemStack(UItems.alfalfa_seeds));
drops.add(new ItemStack(UItems.ALFALFA_SEEDS));
} else if (chance == 1) {
drops.add(new ItemStack(UItems.apple_seeds));
drops.add(new ItemStack(UItems.APPLE_SEEDS));
} else {
drops.add(new ItemStack(UItems.tomato_seeds));
drops.add(new ItemStack(UItems.TOMATO_SEEDS));
}
}
}

View file

@ -12,10 +12,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
public class InteractionManager {
public static InteractionManager instance = new InteractionManager();
public static InteractionManager INSTANCE = new InteractionManager();
public static InteractionManager instance() {
return instance;
return INSTANCE;
}
public boolean isClientPlayer(@Nullable PlayerEntity player) {

View file

@ -1,7 +1,9 @@
package com.minelittlepony.unicopia;
import java.util.HashMap;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.google.common.base.Strings;
@ -23,12 +25,7 @@ public enum Race {
private final boolean flight;
private final boolean earth;
private final static Map<Integer, Race> raceIdMap = new HashMap<>();
static {
for (Race race : values()) {
raceIdMap.put(race.ordinal(), race);
}
}
private final static Map<Integer, Race> REGISTRY = Arrays.stream(values()).collect(Collectors.toMap(Enum::ordinal, Function.identity()));
Race(boolean magic, boolean flight, boolean earth) {
this.magic = magic;
@ -114,6 +111,6 @@ public enum Race {
}
public static Race fromId(int id) {
return raceIdMap.getOrDefault(id, EARTH);
return REGISTRY.getOrDefault(id, EARTH);
}
}

View file

@ -23,30 +23,30 @@ public final class TreeType {
public static final TreeType NONE = new TreeType("none", new Weighted<Supplier<ItemStack>>());
public static final TreeType OAK = new TreeType("oak", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.rotten_apple))
.put(2, () -> new ItemStack(UItems.green_apple))
.put(3, () -> new ItemStack(UItems.VanillaOverrides.red_apple)), Blocks.OAK_LOG, Blocks.OAK_LEAVES);
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.GREEN_APPLE))
.put(3, () -> new ItemStack(UItems.VanillaOverrides.APPLE)), Blocks.OAK_LOG, Blocks.OAK_LEAVES);
public static final TreeType BIRCH = new TreeType("birch", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.rotten_apple))
.put(2, () -> new ItemStack(UItems.sweet_apple))
.put(5, () -> new ItemStack(UItems.green_apple)), Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES);
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(5, () -> new ItemStack(UItems.GREEN_APPLE)), Blocks.BIRCH_LOG, Blocks.BIRCH_LEAVES);
public static final TreeType SPRUCE = new TreeType("spruce", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.sour_apple))
.put(2, () -> new ItemStack(UItems.green_apple))
.put(3, () -> new ItemStack(UItems.sweet_apple))
.put(4, () -> new ItemStack(UItems.rotten_apple)), Blocks.SPRUCE_LOG, Blocks.SPRUCE_LEAVES);
.put(1, () -> new ItemStack(UItems.SOUR_APPLE))
.put(2, () -> new ItemStack(UItems.GREEN_APPLE))
.put(3, () -> new ItemStack(UItems.SWEET_APPLE))
.put(4, () -> new ItemStack(UItems.ROTTEN_APPLE)), Blocks.SPRUCE_LOG, Blocks.SPRUCE_LEAVES);
public static final TreeType ACACIA = new TreeType("acacia", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.rotten_apple))
.put(2, () -> new ItemStack(UItems.sweet_apple))
.put(5, () -> new ItemStack(UItems.green_apple)), Blocks.ACACIA_LOG, Blocks.ACACIA_LEAVES);
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(5, () -> new ItemStack(UItems.GREEN_APPLE)), Blocks.ACACIA_LOG, Blocks.ACACIA_LEAVES);
public static final TreeType JUNGLE = new TreeType("jungle", new Weighted<Supplier<ItemStack>>()
.put(5, () -> new ItemStack(UItems.green_apple))
.put(2, () -> new ItemStack(UItems.sweet_apple))
.put(1, () -> new ItemStack(UItems.sour_apple)), Blocks.JUNGLE_LOG, Blocks.JUNGLE_LEAVES);
.put(5, () -> new ItemStack(UItems.GREEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(1, () -> new ItemStack(UItems.SOUR_APPLE)), Blocks.JUNGLE_LOG, Blocks.JUNGLE_LEAVES);
public static final TreeType DARK_OAK = new TreeType("dark_oak", new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.rotten_apple))
.put(2, () -> new ItemStack(UItems.sweet_apple))
.put(5, () -> new ItemStack(UItems.zap_apple)), Blocks.DARK_OAK_LOG, Blocks.DARK_OAK_LEAVES);
.put(1, () -> new ItemStack(UItems.ROTTEN_APPLE))
.put(2, () -> new ItemStack(UItems.SWEET_APPLE))
.put(5, () -> new ItemStack(UItems.ZAP_APPLE)), Blocks.DARK_OAK_LOG, Blocks.DARK_OAK_LEAVES);
private final String name;
private final Set<Identifier> blocks;

View file

@ -206,7 +206,7 @@ public class BlockGrowingCuccoon extends Block implements Climbable {
BlockState above = world.getBlockState(pos);
if (above.getBlock() == this || above.getBlock() == UBlocks.hive) {
if (above.getBlock() == this || above.getBlock() == UBlocks.HIVE_WALL_BLOCK) {
return true;
}

View file

@ -114,8 +114,8 @@ public class HiveWallBlock extends FallingBlock {
}
} else {
if (pos.getX() % 3 == 0 && pos.getZ() % 4 == 0 && isEmptySpace(world, pos.down()) && UBlocks.cuccoon.getDefaultState().canPlaceAt(world, pos.down())) {
world.setBlockState(pos.down(), UBlocks.cuccoon.getDefaultState());
if (pos.getX() % 3 == 0 && pos.getZ() % 4 == 0 && isEmptySpace(world, pos.down()) && UBlocks.SLIME_DROP.getDefaultState().canPlaceAt(world, pos.down())) {
world.setBlockState(pos.down(), UBlocks.SLIME_DROP.getDefaultState());
} else if (!testForAxis(world, pos, axis)) {
world.setBlockState(pos, state.with(STATE, State.GROWING));
} else if (matchedNeighbours >= 27) {

View file

@ -76,7 +76,7 @@ public class TallCropBlock extends CropBlock {
@Override
protected Item getSeedsItem() {
return UItems.alfalfa_seeds;
return UItems.ALFALFA_SEEDS;
}
@Override

View file

@ -63,7 +63,7 @@ public class TomatoPlantBlock extends CropBlock {
@Override
protected Item getSeedsItem() {
return UItems.tomato_seeds;
return UItems.TOMATO_SEEDS;
}
@Override
@ -78,9 +78,9 @@ public class TomatoPlantBlock extends CropBlock {
@Override
protected boolean canPlantOnTop(BlockState state, BlockView view, BlockPos pos) {
return super.canPlantOnTop(state, view, pos)
|| state.getBlock() == UBlocks.cloud_farmland
|| state.getBlock() == UBlocks.tomato_plant
|| state.getBlock() == UBlocks.stick;
|| state.getBlock() == UBlocks.CLOUD_FARMLAND
|| state.getBlock() == UBlocks.TOMATO_PLANT
|| state.getBlock() == UBlocks.STICK;
}
@Override
@ -164,11 +164,11 @@ public class TomatoPlantBlock extends CropBlock {
}
public Item getCrop() {
return this == CLOUDSDALE ? UItems.cloudsdale_tomato : UItems.tomato;
return this == CLOUDSDALE ? UItems.CLOUDSDALE_TOMATO : UItems.TOMATO;
}
public Item getWaste() {
return this == CLOUDSDALE ? UItems.rotten_cloudsdale_tomato : UItems.rotten_tomato;
return this == CLOUDSDALE ? UItems.ROTTEN_CLOUDSDALE_TOMATO : UItems.ROTTEN_TOMATO;
}
}
}

View file

@ -24,49 +24,49 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public interface UBlocks {
CloudFarmlandBlock cloud_farmland = register(new CloudFarmlandBlock(FabricBlockSettings.of(UMaterials.CLOUD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.WOOL).build()), "cloud_farmland");
CloudBlock normal_cloud = register(new CloudBlock(CloudType.NORMAL), "cloud_block");
CloudBlock enchanted_cloud = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block");
CloudBlock packed_cloud = register(new CloudBlock(CloudType.PACKED), "packed_cloud_block");
CloudFarmlandBlock CLOUD_FARMLAND = register(new CloudFarmlandBlock(FabricBlockSettings.of(UMaterials.CLOUD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.WOOL).build()), "cloud_farmland");
CloudBlock CLOUD_BLOCK = register(new CloudBlock(CloudType.NORMAL), "cloud_block");
CloudBlock ENCHANTED_CLOUD_BLOCK = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block");
CloudBlock DENSE_CLOUD_BLOCK = register(new CloudBlock(CloudType.DENSE), "dense_cloud_block");
CloudStairsBlock cloud_stairs = register(new CloudStairsBlock(normal_cloud.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs");
CloudStairsBlock CLOUD_STAIRS = register(new CloudStairsBlock(CLOUD_BLOCK.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs");
CloudSlabBlock<CloudBlock> cloud_slab = register(new CloudSlabBlock<>(normal_cloud, UMaterials.CLOUD), "cloud_slab");
CloudSlabBlock<CloudBlock> enchanted_cloud_slab = register(new CloudSlabBlock<>(enchanted_cloud, UMaterials.CLOUD), "enchanted_cloud_slab");
CloudSlabBlock<CloudBlock> packed_cloud_slab = register(new CloudSlabBlock<>(enchanted_cloud, UMaterials.CLOUD), "packed_cloud_slab");
CloudSlabBlock<CloudBlock> CLOUD_SLAB = register(new CloudSlabBlock<>(CLOUD_BLOCK, UMaterials.CLOUD), "cloud_slab");
CloudSlabBlock<CloudBlock> ENCHANTED_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK, UMaterials.CLOUD), "enchanted_cloud_slab");
CloudSlabBlock<CloudBlock> DENSE_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK, UMaterials.CLOUD), "dense_cloud_slab");
CloudDoorBlock mist_door = register(new CloudDoorBlock(), "mist_door");
DutchDoorBlock library_door = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "library_door");
DutchDoorBlock bakery_door = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "bakery_door");
DiamondDoorBlock diamond_door = register(new DiamondDoorBlock(), "diamond_door");
CloudDoorBlock MISTED_GLASS_DOOR = register(new CloudDoorBlock(), "misted_glass_door");
DutchDoorBlock LIBRARY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "library_door");
DutchDoorBlock BAKERY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "bakery_door");
DiamondDoorBlock DIAMOND_DOOR = register(new DiamondDoorBlock(), "diamond_door");
GlowingGemBlock enchanted_torch = register(new GlowingGemBlock(), "enchanted_torch");
GlowingGemBlock ENCHANTED_TORCH = register(new GlowingGemBlock(), "enchanted_torch");
CloudAnvilBlock anvil = register(new CloudAnvilBlock(), "anvil");
CloudAnvilBlock CLOUD_ANVIL = register(new CloudAnvilBlock(), "cloud_anvil");
CloudFenceBlock cloud_fence = register(new CloudFenceBlock(CloudType.NORMAL), "cloud_fence");
CloudFenceBlock CLOUD_FENCE = register(new CloudFenceBlock(CloudType.NORMAL), "cloud_fence");
TallCropBlock alfalfa = register(new TallCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).build()), "alfalfa");
TallCropBlock ALFALFA_CROPS = register(new TallCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).build()), "alfalfa_crops");
StickBlock stick = register(new StickBlock(), "stick");
TomatoPlantBlock tomato_plant = register(new TomatoPlantBlock(), "tomato_plant");
StickBlock STICK = register(new StickBlock(), "stick");
TomatoPlantBlock TOMATO_PLANT = register(new TomatoPlantBlock(), "tomato_plant");
HiveWallBlock hive = register(new HiveWallBlock(), "hive");
ChitinBlock chitin_block = register(new ChitinBlock(), "chitin_block");
Block chissled_chitin = register(new ChiselledChitinBlock(), "chissled_chitin");
HiveWallBlock HIVE_WALL_BLOCK = register(new HiveWallBlock(), "hive_wall_block");
ChitinBlock CHITIN_SHELL_BLOCK = register(new ChitinBlock(), "chitin_shell_block");
Block CHISELED_CHITIN_SHELL_BLOCK = register(new ChiselledChitinBlock(), "chiseled_chitin_shell_block");
BlockGrowingCuccoon cuccoon = register(new BlockGrowingCuccoon(), "cuccoon");
SlimeLayerBlock slime_layer = register(new SlimeLayerBlock(), "slime_layer");
BlockGrowingCuccoon SLIME_DROP = register(new BlockGrowingCuccoon(), "slime_drop");
SlimeLayerBlock SLIME_LAYER = register(new SlimeLayerBlock(), "slime_layer");
Block sugar_block = register(new SugarBlock(), "sugar_block");
Block apple_leaves = register(new FruitLeavesBlock()
Block SUGAR_BLOCK = register(new SugarBlock(), "sugar_block");
Block APPLE_LEAVES = register(new FruitLeavesBlock()
.growthChance(1200)
.tint(0xFFEE81)
.fruit(W -> TreeType.OAK.pickRandomStack())
.compost(w -> new ItemStack(UItems.rotten_apple)), "apple_leaves");
.compost(w -> new ItemStack(UItems.ROTTEN_APPLE)), "apple_leaves");
SaplingBlock apple_tree = register(new SaplingBlock(
new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), apple_leaves.getDefaultState()),
SaplingBlock APPLE_SAPLING = register(new SaplingBlock(
new CustomSaplingGenerator(5, Blocks.OAK_LOG.getDefaultState(), APPLE_LEAVES.getDefaultState()),
FabricBlockSettings.of(Material.WOOD).build()
) {}, "apple_sapling");

View file

@ -55,7 +55,7 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
@Override
public void onInitializeClient() {
clientPlayerRace = getclientPlayerRace();
InteractionManager.instance = this;
InteractionManager.INSTANCE = this;
ClientTickCallback.EVENT.register(this::tick);
ClientReadyCallback.EVENT.register(client -> Abilities.getInstance().getValues().forEach(keyboard::addKeybind));
@ -64,14 +64,14 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
ColorProviderRegistry.ITEM.register((stack, tint) -> {
return getLeavesColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tint);
}, UItems.apple_leaves);
ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.apple_leaves);
}, UItems.APPLE_LEAVES);
ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.APPLE_LEAVES);
ColorProviderRegistry.ITEM.register((stack, tint) -> {
if (MAGI.test(MinecraftClient.getInstance().player)) {
return SpellRegistry.instance().getSpellTintFromStack(stack);
}
return 0xFFFFFF;
}, UItems.spell, UItems.curse);
}, UItems.GEM, UItems.CORRUPTED_GEM);
}
private void tick(MinecraftClient client) {
@ -127,7 +127,6 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
}
}
return Config.getInstance().getPrefferedRace();
}

View file

@ -82,7 +82,7 @@ public abstract class AbstractSpecialRecipe implements Recipe<CraftingInventory>
@Override
public ItemStack getRecipeKindIcon() {
return new ItemStack(UItems.spell);
return new ItemStack(UItems.GEM);
}
public SpellIngredient getSpellItem() {

View file

@ -25,7 +25,7 @@ public class SpellRecipe extends AbstractSpecialRecipe {
@Override
public ItemStack getRecipeKindIcon() {
return new ItemStack(UItems.spellbook);
return new ItemStack(UItems.SPELLBOOK);
}
@Override

View file

@ -408,7 +408,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
public void spawnHurtParticles() {
for (int i = 0; i < 50 * getCloudSize(); i++) {
ParticleEmitter.instance().emitDiggingParticles(this, UBlocks.normal_cloud);
ParticleEmitter.instance().emitDiggingParticles(this, UBlocks.CLOUD_BLOCK);
}
playHurtSound(DamageSource.GENERIC);
}
@ -487,10 +487,10 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
if (hitByPlayer) {
int amount = 13 + world.random.nextInt(3);
dropItem(UItems.cloud_matter, amount * (1 + looting));
dropItem(UItems.CLOUD_MATTER, amount * (1 + looting));
if (world.random.nextBoolean()) {
dropItem(UItems.dew_drop, 3 + looting);
dropItem(UItems.DEW_DROP, 3 + looting);
}
}
}

View file

@ -51,7 +51,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerFacto
@Override
public ItemStack getPickedStack() {
return new ItemStack(UItems.spellbook);
return new ItemStack(UItems.SPELLBOOK);
}
@Override
@ -146,7 +146,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerFacto
world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true);
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) {
dropItem(UItems.spellbook, 1);
dropItem(UItems.SPELLBOOK, 1);
}
}
return false;

View file

@ -139,7 +139,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
}
protected Item getItem() {
return getAffinity() == Affinity.BAD ? UItems.curse : UItems.spell;
return getAffinity() == Affinity.BAD ? UItems.CORRUPTED_GEM : UItems.GEM;
}
@Override

View file

@ -28,7 +28,7 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
.build()
);
this.variant = variant;
HoeUtil.registerTillingAction(this, UBlocks.cloud_farmland.getDefaultState());
HoeUtil.registerTillingAction(this, UBlocks.CLOUD_FARMLAND.getDefaultState());
}
@Override

View file

@ -72,6 +72,6 @@ public class CloudFarmlandBlock extends FarmlandBlock implements Farmland, Gas {
@Override
public BlockState getDirtState(BlockState state, World world, BlockPos pos) {
return UBlocks.normal_cloud.getDefaultState();
return UBlocks.CLOUD_BLOCK.getDefaultState();
}
}

View file

@ -12,7 +12,7 @@ import net.minecraft.sound.BlockSoundGroup;
public enum CloudType {
NORMAL,
PACKED,
DENSE,
ENCHANTED;
public FabricBlockSettings configure() {
@ -36,7 +36,7 @@ public enum CloudType {
if (e instanceof PlayerEntity) {
if (this == PACKED) {
if (this == DENSE) {
return true;
}

View file

@ -278,7 +278,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem
@Override
public Ingredient getRepairIngredient() {
return Ingredient.ofItems(UItems.alicorn_amulet);
return Ingredient.ofItems(UItems.ALICORN_AMULET);
}
@Override

View file

@ -39,7 +39,7 @@ public class AppleItem extends Item implements Toxic, ItemEntityCapabilities.Tic
ItemEntity neu = EntityType.ITEM.create(entity.world);
neu.copyPositionAndRotation(entity);
neu.setStack(new ItemStack(UItems.rotten_apple));
neu.setStack(new ItemStack(UItems.ROTTEN_APPLE));
entity.world.spawnEntity(neu);

View file

@ -1,13 +1,12 @@
package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable;
import java.util.Optional;
import com.minelittlepony.unicopia.magic.Dispensable;
import net.minecraft.block.BlockState;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.dispenser.DispenserBehavior;
import net.minecraft.block.dispenser.ItemDispenserBehavior;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
@ -16,43 +15,37 @@ import net.minecraft.item.ItemUsageContext;
import net.minecraft.item.Items;
import net.minecraft.item.ShearsItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class ExtendedShearsItem extends ShearsItem {
public class ExtendedShearsItem extends ShearsItem implements Dispensable {
@Nullable
private static DispenserBehavior vanillaDispenserBehaviour;
private static final DispenserBehavior dispenserBehavior = new ItemDispenserBehavior() {
@Override
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack) {
Direction facing = source.getBlockState().get(DispenserBlock.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
World w = source.getWorld();
if (UItems.moss.tryConvert(w, w.getBlockState(pos), pos, null)) {
stack.damage(1, w.random, null);
return stack;
}
if (vanillaDispenserBehaviour != null) {
return vanillaDispenserBehaviour.dispense(source, stack);
}
return stack;
}
};
private final Optional<DispenserBehavior> vanillaDispenserBehaviour = getBehavior(new ItemStack(Items.SHEARS));
public ExtendedShearsItem() {
super(new Item.Settings().maxDamage(238).group(ItemGroup.TOOLS));
setDispenseable();
DispenserBlock.registerBehavior(Items.SHEARS, getBehavior(new ItemStack(this)).get());
}
vanillaDispenserBehaviour = Dispensable.getBehaviorForItem(new ItemStack(Items.SHEARS));
DispenserBlock.registerBehavior(Items.SHEARS, dispenserBehavior);
DispenserBlock.registerBehavior(this, dispenserBehavior);
@Override
public TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
Direction facing = source.getBlockState().get(DispenserBlock.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
World w = source.getWorld();
if (UItems.MOSS.tryConvert(w, w.getBlockState(pos), pos, null)) {
stack.damage(1, w.random, null);
return TypedActionResult.success(stack);
}
return vanillaDispenserBehaviour
.map(action -> TypedActionResult.success(action.dispense(source, stack)))
.orElseGet(() -> TypedActionResult.fail(stack));
}
@Override
@ -61,7 +54,7 @@ public class ExtendedShearsItem extends ShearsItem {
PlayerEntity player = context.getPlayer();
if (UItems.moss.tryConvert(context.getWorld(), state, context.getBlockPos(), context.getPlayer())) {
if (UItems.MOSS.tryConvert(context.getWorld(), state, context.getBlockPos(), context.getPlayer())) {
if (player != null) {
ItemStack stack = context.getStack();

View file

@ -35,7 +35,7 @@ public class StickItem extends Item {
if (facing == Direction.UP && world.isAir(pos.up()) && (player == null || world.canPlayerModifyAt(player, pos.offset(facing)))) {
world.setBlockState(pos.up(), UBlocks.stick.getDefaultState());
world.setBlockState(pos.up(), UBlocks.STICK.getDefaultState());
BlockSoundGroup sound = world.getBlockState(pos).getSoundGroup();

View file

@ -25,7 +25,7 @@ public class TomatoSeedsItem extends Item {
Block block = state.getBlock();
if (block instanceof StickBlock) {
if (UBlocks.tomato_plant.plant(context.getWorld(), context.getBlockPos(), state)) {
if (UBlocks.TOMATO_PLANT.plant(context.getWorld(), context.getBlockPos(), state)) {
PlayerEntity player = context.getPlayer();
if (player == null || !player.isCreative()) {

View file

@ -33,86 +33,86 @@ import net.minecraft.util.registry.Registry;
public interface UItems {
AppleItem green_apple = register(new AppleItem(FoodComponents.APPLE), "apple_green");
AppleItem sweet_apple = register(new AppleItem(FoodComponents.APPLE), "apple_sweet");
AppleItem sour_apple = register(new AppleItem(FoodComponents.APPLE), "apple_sour");
AppleItem GREEN_APPLE = register(new AppleItem(FoodComponents.APPLE), "apple_green");
AppleItem SWEET_APPLE = register(new AppleItem(FoodComponents.APPLE), "apple_sweet");
AppleItem SOUR_APPLE = register(new AppleItem(FoodComponents.APPLE), "apple_sour");
ZapAppleItem zap_apple = register(new ZapAppleItem(), "zap_apple");
ZapAppleItem ZAP_APPLE = register(new ZapAppleItem(), "zap_apple");
AppleItem rotten_apple = register(new RottenAppleItem(FoodComponents.APPLE), "rotten_apple");
AppleItem ROTTEN_APPLE = register(new RottenAppleItem(FoodComponents.APPLE), "rotten_apple");
AppleItem cooked_zap_apple = register(new AppleItem(FoodComponents.APPLE), "cooked_zap_apple");
Item cloud_matter = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "cloud_matter");
Item dew_drop = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "dew_drop");
Item CLOUD_MATTER = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "cloud_matter");
Item DEW_DROP = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "dew_drop");
CloudPlacerItem racing_cloud_spawner = register(new CloudPlacerItem(UEntities.RACING_CLOUD), "racing_cloud_spawner");
CloudPlacerItem construction_cloud_spawner = register(new CloudPlacerItem(UEntities.CONSTRUCTION_CLOUD), "construction_cloud_spawner");
CloudPlacerItem wild_cloud_spawner = register(new CloudPlacerItem(UEntities.WILD_CLOUD), "wild_cloud_spawner");
CloudPlacerItem RACING_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.RACING_CLOUD), "racing_cloud_spawner");
CloudPlacerItem CONSTRUCTION_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.CONSTRUCTION_CLOUD), "construction_cloud_spawner");
CloudPlacerItem WILD_CLOUD_SPAWNER = register(new CloudPlacerItem(UEntities.WILD_CLOUD), "wild_cloud_spawner");
Item cloud_block = register(new PredicatedBlockItem(UBlocks.normal_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "cloud_block");
Item enchanted_cloud = register(new PredicatedBlockItem(UBlocks.enchanted_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "enchanted_cloud_block");
Item packed_cloud = register(new PredicatedBlockItem(UBlocks.packed_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "packed_cloud_block");
Item CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "cloud_block");
Item ENCHANTED_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "enchanted_cloud_block");
Item PACKED_CLOUD_BLOCK = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "packed_cloud_block");
Item cloud_stairs = register(new PredicatedBlockItem(UBlocks.cloud_stairs, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "cloud_stairs");
Item CLOUD_STAIRS = register(new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "cloud_stairs");
Item cloud_fence = register(new PredicatedBlockItem(UBlocks.cloud_fence, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_fence");
Item CLOUD_FENCE = register(new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_fence");
Item anvil = register(new PredicatedBlockItem(UBlocks.anvil, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_anvil");
Item CLOUD_ANVIL = register(new PredicatedBlockItem(UBlocks.CLOUD_ANVIL, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_anvil");
Item record_crusade = register(createRecord(USounds.RECORD_CRUSADE), "crusade");
Item record_pet = register(createRecord(USounds.RECORD_PET), "pet");
Item record_popular = register(createRecord(USounds.RECORD_POPULAR), "popular");
Item record_funk = register(createRecord(USounds.RECORD_FUNK), "funk");
Item MUSIC_DISC_CRUSADE = register(createRecord(USounds.RECORD_CRUSADE), "music_disc_crusade");
Item MUSIC_DISC_PET = register(createRecord(USounds.RECORD_PET), "music_disc_pet");
Item MUSIC_DISC_POPULAR = register(createRecord(USounds.RECORD_POPULAR), "music_disc_popular");
Item MUSIC_DISC_FUNK = register(createRecord(USounds.RECORD_FUNK), "music_disc_funk");
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 = 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 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 HIVE_WALL_BLOCK = register(new BlockItem(UBlocks.HIVE_WALL_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "hive_wall_block");
Item CHITIN_SHELL = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "chitin_shell");
Item CHITIN_SHELL_BLOCK = register(new BlockItem(UBlocks.CHITIN_SHELL_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chitin_shell_block");
Item CHISELED_CHITIN_SHELL_BLOCK = register(new BlockItem(UBlocks.CHISELED_CHITIN_SHELL_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chiseled_chitin_shell_block");
Item SLIME_DROP = register(new BlockItem(UBlocks.SLIME_DROP, new Item.Settings().group(ItemGroup.MATERIALS)), "slime_drop");
Item SLIME_LAYER = register(new BlockItem(UBlocks.SLIME_LAYER, new Item.Settings().group(ItemGroup.DECORATIONS)), "slime_layer");
Item mist_door = register(new TallBlockItem(UBlocks.mist_door, new Item.Settings().group(ItemGroup.REDSTONE)), "mist_door");
Item library_door = register(new TallBlockItem(UBlocks.library_door, new Item.Settings().group(ItemGroup.REDSTONE)), "library_door");
Item bakery_door = register(new TallBlockItem(UBlocks.bakery_door, new Item.Settings().group(ItemGroup.REDSTONE)), "bakery_door");
Item diamond_door = register(new TallBlockItem(UBlocks.diamond_door, new Item.Settings().group(ItemGroup.REDSTONE)), "diamond_door");
Item MISTED_DOOR = register(new TallBlockItem(UBlocks.MISTED_GLASS_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "misted_door");
Item LIBRARY_DOOR = register(new TallBlockItem(UBlocks.LIBRARY_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "library_door");
Item BAKERY_DOOR = register(new TallBlockItem(UBlocks.BAKERY_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "bakery_door");
Item DIAMOND_DOOR = register(new TallBlockItem(UBlocks.DIAMOND_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "diamond_door");
Item sugar_block = register(new BlockItem(UBlocks.sugar_block, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "sugar_block");
Item SUGAR_BLOCK = register(new BlockItem(UBlocks.SUGAR_BLOCK, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "sugar_block");
Item cloud_slab = new PredicatedBlockItem(UBlocks.cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
Item enchanted_cloud_slab = new PredicatedBlockItem(UBlocks.enchanted_cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
Item packed_cloud_slab = new PredicatedBlockItem(UBlocks.packed_cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
Item CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.CLOUD_SLAB, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "cloud_slab");
Item ENCHANTED_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_SLAB, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "enchanted_cloud_slab");
Item DENSE_CLOUD_SLAB = register(new PredicatedBlockItem(UBlocks.DENSE_CLOUD_SLAB, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "dense_cloud_slab");
MagicGemItem spell = register(new MagicGemItem(), "gem");
MagicGemItem curse = register(new CursedMagicGemItem(), "corrupted_gem");
MagicGemItem GEM = register(new MagicGemItem(), "gem");
MagicGemItem CORRUPTED_GEM = register(new CursedMagicGemItem(), "corrupted_gem");
BagOfHoldingItem bag_of_holding = register(new BagOfHoldingItem(), "bag_of_holding");
AlicornAmuletItem alicorn_amulet = register(new AlicornAmuletItem(), "alicorn_amulet");
BagOfHoldingItem BAG_OF_HOLDING = register(new BagOfHoldingItem(), "bag_of_holding");
AlicornAmuletItem ALICORN_AMULET = register(new AlicornAmuletItem(), "alicorn_amulet");
SpellbookItem spellbook = register(new SpellbookItem(), "spellbook");
Item staff_meadow_brook = register(new StaffItem(new Item.Settings().maxCount(1).maxDamage(2)), "staff_meadow_brook");
Item staff_remembrance = register(new EnchantedStaffItem(new Item.Settings(), new ScorchSpell()), "staff_remembrance");
SpellbookItem SPELLBOOK = register(new SpellbookItem(), "spellbook");
Item STAFF_MEADOW_BROOK = register(new StaffItem(new Item.Settings().maxCount(1).maxDamage(2)), "staff_meadow_brook");
Item STAFF_REMEMBERANCE = register(new EnchantedStaffItem(new Item.Settings(), new ScorchSpell()), "staff_remembrance");
Item spear = register(new SpearItem(new Item.Settings().maxCount(1).maxDamage(500)), "spear");
Item SPEAR = register(new SpearItem(new Item.Settings().maxCount(1).maxDamage(500)), "spear");
MossItem moss = register(new MossItem(new Item.Settings()), "moss");
MossItem MOSS = register(new MossItem(new Item.Settings()), "moss");
Item alfalfa_seeds = register(new AliasedBlockItem(UBlocks.alfalfa, new Item.Settings()
Item ALFALFA_SEEDS = register(new AliasedBlockItem(UBlocks.ALFALFA_CROPS, new Item.Settings()
.group(ItemGroup.MATERIALS)
.food(new FoodComponent.Builder()
.hunger(1)
.saturationModifier(4)
.build())), "alfalfa_seeds");
Item enchanted_torch = register(new BlockItem(UBlocks.enchanted_torch, new Item.Settings().group(ItemGroup.DECORATIONS)), "enchanted_torch");
Item alfalfa_leaves = register(new Item(new Item.Settings()
Item ALFALFA_LEAVES = register(new Item(new Item.Settings()
.group(ItemGroup.FOOD)
.food(new FoodComponent.Builder()
.hunger(1)
.saturationModifier(3)
.build())), "alfalfa_leaves");
Item cereal = register(new SugaryItem(new Item.Settings()
Item ENCHANTED_TORCH = register(new BlockItem(UBlocks.ENCHANTED_TORCH, new Item.Settings().group(ItemGroup.DECORATIONS)), "enchanted_torch");
Item CEREAL = register(new SugaryItem(new Item.Settings()
.group(ItemGroup.FOOD)
.food(new FoodComponent.Builder()
.hunger(9)
@ -120,7 +120,7 @@ public interface UItems {
.build())
.maxCount(1)
.recipeRemainder(Items.BOWL), 1), "cereal");
Item sugar_cereal = register(new SugaryItem(new Item.Settings()
Item SUGAR_CEREAL = register(new SugaryItem(new Item.Settings()
.group(ItemGroup.FOOD)
.food(new FoodComponent.Builder()
.hunger(20)
@ -129,30 +129,29 @@ public interface UItems {
.maxCount(1)
.recipeRemainder(Items.BOWL), 110), "sugar_cereal");
TomatoItem tomato = register(new TomatoItem(4, 34), "tomato");
RottenTomatoItem rotten_tomato = register(new RottenTomatoItem(4, 34), "rotten_tomato");
TomatoSeedsItem TOMATO_SEEDS = register(new TomatoSeedsItem(), "tomato_seeds");
TomatoItem TOMATO = register(new TomatoItem(4, 34), "tomato");
RottenTomatoItem ROTTEN_TOMATO = register(new RottenTomatoItem(4, 34), "rotten_tomato");
TomatoItem cloudsdale_tomato = register(new TomatoItem(16, 4), "cloudsdale_tomato");
RottenTomatoItem rotten_cloudsdale_tomato = register(new RottenTomatoItem(5, 34), "rotten_cloudsdale_tomato");
TomatoItem CLOUDSDALE_TOMATO = register(new TomatoItem(16, 4), "cloudsdale_tomato");
RottenTomatoItem ROTTEN_CLOUDSDALE_TOMATO = register(new RottenTomatoItem(5, 34), "rotten_cloudsdale_tomato");
TomatoSeedsItem tomato_seeds = register(new TomatoSeedsItem(), "tomato_seeds");
Item APPLE_SEEDS = register(new BlockItem(UBlocks.APPLE_SAPLING, new Item.Settings().group(ItemGroup.DECORATIONS)), "apple_seeds");
Item APPLE_LEAVES = register(new BlockItem(UBlocks.APPLE_LEAVES, new Item.Settings().group(ItemGroup.DECORATIONS)), "apple_leaves");
Item apple_seeds = register(new BlockItem(UBlocks.apple_tree, new Item.Settings().group(ItemGroup.DECORATIONS)), "apple_seeds");
Item apple_leaves = register(new BlockItem(UBlocks.apple_leaves, new Item.Settings().group(ItemGroup.DECORATIONS)), "apple_leaves");
Item DAFFODIL_DAISY_SANDWICH = register(new DynamicToxicItem(new Item.Settings(), 3, 2, UseAction.EAT, Toxicity::fromStack), "daffodil_daisy_sandwich");
Item HAY_BURGER = register(new DynamicToxicItem(new Item.Settings(), 3, 4, UseAction.EAT, Toxicity::fromStack), "hay_burger");
Item HAY_FRIES = register(new ToxicItem(new Item.Settings(), 1, 5, UseAction.EAT, Toxicity.SAFE), "hay_fries");
Item SALAD = register(new DynamicToxicItem(new Item.Settings().recipeRemainder(Items.BOWL), 4, 2, UseAction.EAT, Toxicity::fromStack), "salad");
Item daffodil_daisy_sandwich = register(new DynamicToxicItem(new Item.Settings(), 3, 2, UseAction.EAT, Toxicity::fromStack), "daffodil_daisy_sandwich");
Item hay_burger = register(new DynamicToxicItem(new Item.Settings(), 3, 4, UseAction.EAT, Toxicity::fromStack), "hay_burger");
Item hay_fries = register(new ToxicItem(new Item.Settings(), 1, 5, UseAction.EAT, Toxicity.SAFE), "hay_fries");
Item salad = register(new DynamicToxicItem(new Item.Settings().recipeRemainder(Items.BOWL), 4, 2, UseAction.EAT, Toxicity::fromStack), "salad");
Item WHEAT_WORMS = register(new ToxicItem(new Item.Settings(), 1, 0, UseAction.EAT, Toxicity.SEVERE), "wheat_worms");
Item MUG = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "mug");
Item CIDER = register(new ToxicItem(new Item.Settings().recipeRemainder(MUG), 4, 2, UseAction.DRINK, Toxicity.MILD), "apple_cider");
Item JUICE = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 2, 2, UseAction.DRINK, Toxicity.SAFE), "juice");
Item BURNED_JUICE = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 3, 1, UseAction.DRINK, Toxicity.FAIR), "burned_juice");
Item wheat_worms = register(new ToxicItem(new Item.Settings(), 1, 0, UseAction.EAT, Toxicity.SEVERE), "wheat_worms");
Item mug = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "mug");
Item apple_cider = register(new ToxicItem(new Item.Settings().recipeRemainder(mug), 4, 2, UseAction.DRINK, Toxicity.MILD), "apple_cider");
Item juice = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 2, 2, UseAction.DRINK, Toxicity.SAFE), "juice");
Item burned_juice = register(new ToxicItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE), 3, 1, UseAction.DRINK, Toxicity.FAIR), "burned_juice");
Item cloud_spawn_egg = register(new SpawnEggItem(UEntities.CLOUD, 0x4169e1, 0x7fff00, new Item.Settings().group(ItemGroup.MISC)), "cloud_spawn_egg");
Item butterfly_spawn_egg = register(new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Item.Settings().group(ItemGroup.MISC)), "cloud_spawn_egg");
Item CLOUD_SPAWN_EGG = register(new SpawnEggItem(UEntities.CLOUD, 0x4169e1, 0x7fff00, new Item.Settings().group(ItemGroup.MISC)), "cloud_spawn_egg");
Item BUTTERFLY_SPAWN_EGG = register(new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Item.Settings().group(ItemGroup.MISC)), "cloud_spawn_egg");
static <T extends Item> T register(T item, String name) {
return Registry.ITEM.add(new Identifier(Unicopia.MODID, name), item);
@ -173,31 +172,31 @@ public interface UItems {
}
interface VanillaOverrides {
StickItem stick = register(new StickItem(), Items.STICK);
ExtendedShearsItem shears = register(new ExtendedShearsItem(), Items.SHEARS);
StickItem STICK = register(new StickItem(), Items.STICK);
ExtendedShearsItem SHEARS = register(new ExtendedShearsItem(), Items.SHEARS);
AppleItem red_apple = register(new AppleItem(FoodComponents.APPLE), Items.APPLE);
AppleItem APPLE = register(new AppleItem(FoodComponents.APPLE), Items.APPLE);
Item grass = register(new DynamicToxicBlockItem(Blocks.GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.NAUSEA), Items.GRASS);
Item fern = register(new DynamicToxicBlockItem(Blocks.FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.STRENGTH), Items.FERN);
Item dead_bush = register(new DynamicToxicBlockItem(Blocks.DEAD_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.NAUSEA), Items.DEAD_BUSH);
Item GRASS = register(new DynamicToxicBlockItem(Blocks.GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.NAUSEA), Items.GRASS);
Item FERN = register(new DynamicToxicBlockItem(Blocks.FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.STRENGTH), Items.FERN);
Item DEAD_BUSH = register(new DynamicToxicBlockItem(Blocks.DEAD_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.NAUSEA), Items.DEAD_BUSH);
Item dandelion = register(new ToxicBlockItem(Blocks.DANDELION, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.DANDELION);
Item poppy = register(new ToxicBlockItem(Blocks.POPPY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE), Items.POPPY);
Item blue_orchid = register(new ToxicBlockItem(Blocks.BLUE_ORCHID, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.BLUE_ORCHID);
Item allium = register(new ToxicBlockItem(Blocks.ALLIUM, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR), Items.ALLIUM);
Item azure_bluet = register(new DynamicToxicBlockItem(Blocks.AZURE_BLUET, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.RADIOACTIVITY), Items.AZURE_BLUET);
Item red_tulip = register(new ToxicBlockItem(Blocks.RED_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.RED_TULIP);
Item orange_tulip = register(new ToxicBlockItem(Blocks.ORANGE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.ORANGE_TULIP);
Item white_tulip = register(new ToxicBlockItem(Blocks.WHITE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR), Items.WHITE_TULIP);
Item pink_tulip = register(new ToxicBlockItem(Blocks.PINK_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PINK_TULIP);
Item oxeye_daisy = register(new DynamicToxicBlockItem(Blocks.OXEYE_DAISY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.BLINDNESS), Items.OXEYE_DAISY);
Item cornflower = register(new ToxicBlockItem(Blocks.CORNFLOWER, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.CORNFLOWER);
Item DANDELION = register(new ToxicBlockItem(Blocks.DANDELION, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.DANDELION);
Item POPPY = register(new ToxicBlockItem(Blocks.POPPY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE), Items.POPPY);
Item BLUE_ORCHID = register(new ToxicBlockItem(Blocks.BLUE_ORCHID, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.BLUE_ORCHID);
Item ALLIUM = register(new ToxicBlockItem(Blocks.ALLIUM, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR), Items.ALLIUM);
Item AZUER_BLUET = register(new DynamicToxicBlockItem(Blocks.AZURE_BLUET, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.RADIOACTIVITY), Items.AZURE_BLUET);
Item RED_TULIP = register(new ToxicBlockItem(Blocks.RED_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.RED_TULIP);
Item ORANGE_TULIP = register(new ToxicBlockItem(Blocks.ORANGE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.ORANGE_TULIP);
Item WHITE_TULIP = register(new ToxicBlockItem(Blocks.WHITE_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.FAIR), Items.WHITE_TULIP);
Item PINK_TULIP = register(new ToxicBlockItem(Blocks.PINK_TULIP, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PINK_TULIP);
Item OXEYE_DAISY = register(new DynamicToxicBlockItem(Blocks.OXEYE_DAISY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.BLINDNESS), Items.OXEYE_DAISY);
Item CORNFLOWER = register(new ToxicBlockItem(Blocks.CORNFLOWER, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.CORNFLOWER);
Item rose_bush = register(new DynamicToxicBlockItem(Blocks.ROSE_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.DAMAGE), Items.ROSE_BUSH);
Item peony = register(new ToxicBlockItem(Blocks.PEONY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PEONY);
Item tall_grass = register(new ToxicBlockItem(Blocks.TALL_GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.TALL_GRASS);
Item large_fern = register(new DynamicToxicBlockItem(Blocks.LARGE_FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.DAMAGE), Items.LARGE_FERN);
Item ROSE_BUSH = register(new DynamicToxicBlockItem(Blocks.ROSE_BUSH, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE, Toxin.DAMAGE), Items.ROSE_BUSH);
Item PEONY = register(new ToxicBlockItem(Blocks.PEONY, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.PEONY);
Item TALL_GRASS = register(new ToxicBlockItem(Blocks.TALL_GRASS, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SAFE), Items.TALL_GRASS);
Item LARGE_FERN = register(new DynamicToxicBlockItem(Blocks.LARGE_FERN, new Item.Settings().group(ItemGroup.DECORATIONS), 2, 1, UseAction.EAT, Toxicity.SEVERE, Toxin.DAMAGE), Items.LARGE_FERN);
static <T extends Item> T register(T newItem, Item oldItem) {
return Registry.ITEM.set(Registry.ITEM.getRawId(oldItem), Registry.ITEM.getId(oldItem), newItem);

View file

@ -35,11 +35,11 @@ import net.minecraft.world.World;
public class ZapAppleItem extends AppleItem {
private static final List<Item> ALIASABLE_ITEMS = Lists.newArrayList(
UItems.VanillaOverrides.red_apple,
UItems.green_apple,
UItems.sweet_apple,
UItems.sour_apple,
UItems.rotten_apple,
UItems.VanillaOverrides.APPLE,
UItems.GREEN_APPLE,
UItems.SWEET_APPLE,
UItems.SOUR_APPLE,
UItems.ROTTEN_APPLE,
UItems.cooked_zap_apple
);

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.magic;
import java.util.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.Material;
@ -37,15 +39,15 @@ public interface Dispensable {
*/
TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack);
static DispenserBehavior getBehaviorForItem(ItemStack stack) {
return DispenserAccess.INSTANCE.getBehaviorForItem(stack);
default Optional<DispenserBehavior> getBehavior(ItemStack stack) {
return Optional.ofNullable(DispenserAccess.INSTANCE.getBehaviorForItem(stack));
}
}
class DispenserAccess extends DispenserBlock {
final class DispenserAccess extends DispenserBlock {
static final DispenserAccess INSTANCE = new DispenserAccess();
private DispenserAccess() {
super(Block.Settings.of(Material.BUBBLE_COLUMN));
super(Block.Settings.of(Material.AIR));
}
@Override

View file

@ -30,7 +30,7 @@ public interface TossedMagicEffect extends MagicEffect, Tossable<Caster<?>> {
* Gets the appearance to be used when projecting this spell.
*/
default ItemStack getCastAppearance(Caster<?> caster) {
Item item = getAffinity() == Affinity.BAD ? UItems.curse : UItems.spell;
Item item = getAffinity() == Affinity.BAD ? UItems.CORRUPTED_GEM : UItems.GEM;
return SpellRegistry.instance().enchantStack(new ItemStack(item), getName());
}

View file

@ -94,10 +94,10 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff
}
BlockState state = caster.getWorld().getBlockState(origin);
BlockState slimeState = UBlocks.slime_layer.getDefaultState();
BlockState slimeState = UBlocks.SLIME_LAYER.getDefaultState();
if (slimeState.canPlaceAt(caster.getWorld(), origin)) {
if (caster.getWorld().isAir(origin) || (state.getBlock() != UBlocks.slime_layer && state.canReplace(new AutomaticItemPlacementContext(caster.getWorld(), origin, Direction.DOWN, new ItemStack(UBlocks.slime_layer), Direction.UP)))) {
if (caster.getWorld().isAir(origin) || (state.getBlock() != UBlocks.SLIME_LAYER && state.canReplace(new AutomaticItemPlacementContext(caster.getWorld(), origin, Direction.DOWN, new ItemStack(UBlocks.SLIME_LAYER), Direction.UP)))) {
caster.getWorld().setBlockState(origin, slimeState);
}
}