Porting to Fabric/Yarn/1.14 part 2

This commit is contained in:
Sollace 2020-01-16 16:46:24 +01:00
parent 2670d5cdb6
commit 897287600b
88 changed files with 867 additions and 1129 deletions

View file

@ -1,6 +1,6 @@
package com.minelittlepony.transform;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
import com.minelittlepony.util.math.MathUtil;
@ -8,7 +8,7 @@ import com.minelittlepony.util.math.MathUtil;
//#MineLittlePony#
public abstract class MotionCompositor {
protected double calculateRoll(EntityPlayer player, double motionX, double motionY, double motionZ) {
protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) {
// since model roll should probably be calculated from model rotation rather than entity rotation...
double roll = MathUtil.sensibleAngle(player.prevRenderYawOffset - player.renderYawOffset);
@ -32,7 +32,7 @@ public abstract class MotionCompositor {
return MathHelper.clamp(roll, -54, 54);
}
protected double calculateIncline(EntityPlayer player, double motionX, double motionY, double motionZ) {
protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) {
double dist = Math.sqrt(motionX * motionX + motionZ * motionZ);
double angle = Math.atan2(motionY, dist);

View file

@ -23,7 +23,6 @@ import com.minelittlepony.unicopia.block.SugarBlock;
import com.minelittlepony.unicopia.block.UPot;
import com.minelittlepony.unicopia.block.USapling;
import com.minelittlepony.unicopia.block.BlockTomatoPlant;
import com.minelittlepony.unicopia.item.ItemApple;
import com.minelittlepony.unicopia.block.BlockCloudDoor;
import com.minelittlepony.unicopia.block.BlockDiamondDoor;
import com.minelittlepony.unicopia.block.BlockCloudFarm;
@ -40,11 +39,13 @@ import net.minecraft.client.color.world.BiomeColors;
import net.minecraft.client.color.world.GrassColors;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class UBlocks {
public static final BlockCloud normal_cloud = register(new BlockCloud(UMaterials.cloud, CloudType.NORMAL, Unicopia.MODID, "cloud_block"));
public static final BlockCloud enchanted_cloud = register(new BlockCloud(UMaterials.cloud, CloudType.ENCHANTED, Unicopia.MODID, "enchanted_cloud_block"));
public static final BlockCloud packed_cloud = register(new BlockCloud(UMaterials.cloud, CloudType.PACKED, Unicopia.MODID, "packed_cloud_block"));
public static final BlockCloud normal_cloud = register(new BlockCloud(UMaterials.cloud, CloudType.NORMAL), "cloud_block");
public static final BlockCloud enchanted_cloud = register(new BlockCloud(UMaterials.cloud, CloudType.ENCHANTED), "enchanted_cloud_block");
public static final BlockCloud packed_cloud = register(new BlockCloud(UMaterials.cloud, CloudType.PACKED), "packed_cloud_block");
public static final BlockCloudStairs cloud_stairs = register(new BlockCloudStairs(normal_cloud.getDefaultState(), Unicopia.MODID, "cloud_stairs"));
@ -70,19 +71,19 @@ public class UBlocks {
public static final BlockAlfalfa alfalfa = register(new BlockAlfalfa(Unicopia.MODID, "alfalfa"));
public static final StickBlock stick = register(new StickBlock(Unicopia.MODID, "stick"));
public static final StickBlock stick = register(new StickBlock(), "stick");
public static final BlockTomatoPlant tomato_plant = register(new BlockTomatoPlant(Unicopia.MODID, "tomato_plant"));
public static final BlockCloudFarm cloud_farmland = register(new BlockCloudFarm(Unicopia.MODID, "cloud_farmland"));
public static final HiveWallBlock hive = register(new HiveWallBlock(Unicopia.MODID, "hive"));
public static final ChitinBlock chitin = register(new ChitinBlock(Unicopia.MODID, "chitin_block"));
public static final Block chissled_chitin = register(new ChiselledChitinBlock(Unicopia.MODID, "chissled_chitin"));
public static final HiveWallBlock hive = register(new HiveWallBlock(), "hive");
public static final ChitinBlock chitin = register(new ChitinBlock(), "chitin_block");
public static final Block chissled_chitin = register(new ChiselledChitinBlock(), "chissled_chitin");
public static final BlockGrowingCuccoon cuccoon = register(new BlockGrowingCuccoon(Unicopia.MODID, "cuccoon"));
public static final SlimeLayerBlock slime_layer = register(new SlimeLayerBlock(Unicopia.MODID, "slime_layer"));
public static final SlimeLayerBlock slime_layer = register(new SlimeLayerBlock(), "slime_layer");
public static final Block sugar_block = register(new SugarBlock(Unicopia.MODID, "sugar_block"));
public static final Block sugar_block = register(new SugarBlock(), "sugar_block");
public static final UPot flower_pot = register(new UPot(), "flower_pot");
public static final USapling apple_tree = register(new USapling(Unicopia.MODID, "apple_sapling")
@ -91,17 +92,16 @@ public class UBlocks {
.growthChance(1200)
.tint(0xFFEE81)
.fruit(ItemApple::getRandomItemStack)
.compost(w -> new ItemStack(UItems.rotten_apple))), "apple_leaves");
.compost(w -> new ItemStack(UItems.rotten_apple)), "apple_leaves");
private static <T extends Block> T register(T block) {
return block;
private static <T extends Block> T register(T block, String name) {
return Registry.BLOCK.add(new Identifier(Unicopia.MODID, name), block);
}
static void registerColors(ItemColors items, BlockColors blocks) {
items.register((stack, tint) -> {
@SuppressWarnings("deprecation")
BlockState state = ((BlockItem)stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata());
BlockState state = ((BlockItem)stack.getItem()).getBlock().getDefaultState();
return blocks.getColorMultiplier(state, null, null, tint);
}, apple_leaves);
@ -120,5 +120,7 @@ public class UBlocks {
}, apple_leaves);
}
static void bootstrap() { }
static void bootstrap() {
}
}

View file

@ -62,7 +62,7 @@ public class UClient {
/**
* Side-independent method to create a new player.
*
* Returns an implementation of EntityPlayer appropriate to the side being called on.
* Returns an implementation of PlayerEntity appropriate to the side being called on.
*/
@Nonnull
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {

View file

@ -1,10 +1,10 @@
package com.minelittlepony.unicopia;
import com.minelittlepony.unicopia.item.ItemAlicornAmulet;
import com.minelittlepony.unicopia.item.ItemApple;
import com.minelittlepony.unicopia.item.ItemAppleMultiType;
import com.minelittlepony.unicopia.item.ItemCereal;
import com.minelittlepony.unicopia.item.ItemCloudPlacer;
import com.minelittlepony.unicopia.item.AppleItem;
import com.minelittlepony.unicopia.item.CloudPlacerItem;
import com.minelittlepony.unicopia.item.ItemCurse;
import com.minelittlepony.unicopia.item.ItemFruitLeaves;
import com.minelittlepony.unicopia.item.ItemMagicStaff;
@ -19,34 +19,26 @@ import com.minelittlepony.unicopia.item.ItemStaff;
import com.minelittlepony.unicopia.item.ItemTomato;
import com.minelittlepony.unicopia.item.ItemTomatoSeeds;
import com.minelittlepony.unicopia.item.ItemZapApple;
import com.minelittlepony.unicopia.item.UItemBlock;
import com.minelittlepony.unicopia.item.UItemDecoration;
import com.minelittlepony.unicopia.item.UItemSlab;
import com.minelittlepony.unicopia.item.PredicatedBlockItem;
import com.minelittlepony.unicopia.item.URecord;
import com.minelittlepony.unicopia.item.override.ItemShear;
import com.minelittlepony.unicopia.item.override.ItemStick;
import com.minelittlepony.unicopia.spell.SpellRegistry;
import com.minelittlepony.unicopia.spell.SpellScorch;
import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockFlower;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemDoor;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeedFood;
import net.minecraft.item.ItemGroup;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.item.BlockItem;
import net.minecraft.item.FoodComponents;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.Items;
import net.minecraft.item.TallBlockItem;
import net.minecraft.item.Item.Settings;
import net.minecraft.util.Identifier;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraft.util.registry.Registry;
import static com.minelittlepony.unicopia.Predicates.*;
@ -63,96 +55,72 @@ import com.minelittlepony.unicopia.edibles.UItemFoodDelegate;
import com.minelittlepony.unicopia.entity.EntityConstructionCloud;
import com.minelittlepony.unicopia.entity.EntityRacingCloud;
import com.minelittlepony.unicopia.entity.EntityWildCloud;
import com.minelittlepony.unicopia.extern.Baubles;
import com.minelittlepony.unicopia.forgebullshit.BuildInTexturesBakery;
import com.minelittlepony.unicopia.forgebullshit.ItemRegistrar;
import com.minelittlepony.unicopia.forgebullshit.OreReplacer;
import com.minelittlepony.unicopia.forgebullshit.RegistryLockSpinner;
import com.minelittlepony.unicopia.forgebullshit.UnFuckedItemSnow;
public class UItems {
public static final ItemApple red_apple = new ItemApple("minecraft", "apple");
public static final ItemApple green_apple = new ItemApple(Unicopia.MODID, "apple_green");
public static final ItemApple sweet_apple = new ItemApple(Unicopia.MODID, "apple_sweet");
public static final ItemApple sour_apple = new ItemApple(Unicopia.MODID, "apple_sour");
private static final ItemStick stick = register(new ItemStick(new Item.Settings()), "minecraft", "stick");
private static final ItemShear shears = register(new ItemShear(), "minecraft", "shears");
public static final AppleItem red_apple = register(new AppleItem(FoodComponents.APPLE), "minecraft", "apple");
public static final AppleItem green_apple = register(new AppleItem(FoodComponents.APPLE), "apple_green");
public static final AppleItem sweet_apple = register(new AppleItem(FoodComponents.APPLE), "apple_sweet");
public static final AppleItem sour_apple = register(new AppleItem(FoodComponents.APPLE), "apple_sour");
public static final ItemAppleMultiType zap_apple = new ItemZapApple(Unicopia.MODID, "zap_apple")
.setSubTypes("zap_apple", "red", "green", "sweet", "sour", "zap");
public static final ItemApple rotten_apple = new ItemRottenApple(Unicopia.MODID, "rotten_apple");
public static final ItemApple cooked_zap_apple = new ItemApple(Unicopia.MODID, "cooked_zap_apple");
public static final AppleItem rotten_apple = new ItemRottenApple(Unicopia.MODID, "rotten_apple");
public static final AppleItem cooked_zap_apple = register(new AppleItem(FoodComponents.APPLE), "cooked_zap_apple");
public static final Item cloud_matter = new Item()
.setCreativeTab(CreativeTabs.MATERIALS)
.setTranslationKey("cloud_matter")
.setRegistryName(Unicopia.MODID, "cloud_matter");
public static final Item cloud_matter = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "cloud_matter");
public static final Item dew_drop = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "dew_drop");
public static final Item dew_drop = new Item()
.setCreativeTab(CreativeTabs.MATERIALS)
.setTranslationKey("dew_drop")
.setRegistryName(Unicopia.MODID, "dew_drop");
public static final CloudPlacerItem racing_cloud_spawner = register(new CloudPlacerItem(EntityRacingCloud::new), "racing_cloud_spawner");
public static final CloudPlacerItem construction_cloud_spawner = register(new CloudPlacerItem(EntityConstructionCloud::new), "construction_cloud_spawner");
public static final CloudPlacerItem wild_cloud_spawner = register(new CloudPlacerItem(EntityWildCloud::new), "wild_cloud_spawner");
public static final ItemCloudPlacer racing_cloud_spawner = new ItemCloudPlacer(EntityRacingCloud::new, Unicopia.MODID, "racing_cloud_spawner");
public static final ItemCloudPlacer construction_cloud_spawner = new ItemCloudPlacer(EntityConstructionCloud::new, Unicopia.MODID, "construction_cloud_spawner");
public static final ItemCloudPlacer wild_cloud_spawner = new ItemCloudPlacer(EntityWildCloud::new, Unicopia.MODID, "wild_cloud_spawner");
public static final Item cloud_block = register(new PredicatedBlockItem(UBlocks.normal_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "cloud_block");
public static final Item enchanted_cloud = register(new PredicatedBlockItem(UBlocks.enchanted_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "enchanted_cloud_block");
public static final Item packed_cloud = register(new PredicatedBlockItem(UBlocks.packed_cloud, new Item.Settings().group(ItemGroup.MATERIALS), INTERACT_WITH_CLOUDS), "packed_cloud_block");
public static final Item cloud_block = new UItemBlock(UBlocks.normal_cloud, INTERACT_WITH_CLOUDS);
public static final Item enchanted_cloud = new UItemBlock(UBlocks.enchanted_cloud, INTERACT_WITH_CLOUDS);
public static final Item packed_cloud = new UItemBlock(UBlocks.packed_cloud, INTERACT_WITH_CLOUDS);
public static final Item cloud_stairs = register(new PredicatedBlockItem(UBlocks.cloud_stairs, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS), "cloud_stairs");
public static final Item cloud_stairs = new UItemBlock(UBlocks.cloud_stairs, INTERACT_WITH_CLOUDS);
public static final Item cloud_fence = register(new PredicatedBlockItem(UBlocks.cloud_fence, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_fence");
public static final Item cloud_banister = register(new PredicatedBlockItem(UBlocks.cloud_banister, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_banister");
public static final Item cloud_farmland = new UItemBlock(UBlocks.cloud_farmland, INTERACT_WITH_CLOUDS);
public static final Item anvil = register(new PredicatedBlockItem(UBlocks.anvil, new Item.Settings().group(ItemGroup.DECORATIONS), INTERACT_WITH_CLOUDS), "cloud_anvil");
public static final Item cloud_fence = new UItemBlock(UBlocks.cloud_fence, INTERACT_WITH_CLOUDS);
public static final Item cloud_banister = new UItemBlock(UBlocks.cloud_banister, INTERACT_WITH_CLOUDS);
public static final Item record_crusade = register(new URecord(USounds.RECORD_CRUSADE), "crusade");
public static final Item record_pet = register(new URecord(USounds.RECORD_PET, "pet");
public static final Item record_popular = register(new URecord(USounds.RECORD_POPULAR), "popular");
public static final Item record_funk = register(new URecord(USounds.RECORD_FUNK), "funk");
public static final Item anvil = new UItemBlock(UBlocks.anvil, INTERACT_WITH_CLOUDS).setTranslationKey("cloud_anvil");
public static final Item hive = register(new BlockItem(UBlocks.hive, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "hive");
public static final Item chitin_shell = register(new Item(new Item.Settings().group(ItemGroup.MATERIALS)), "chitin_shell");
public static final Item chitin = register(new BlockItem(UBlocks.chitin, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chitin_block");
public static final Item chissled_chitin = register(new BlockItem(UBlocks.chissled_chitin, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "chissled_chitin");
public static final Item cuccoon = register(new BlockItem(UBlocks.cuccoon, new Item.Settings().group(ItemGroup.MATERIALS)), "cuccoon");
public static final Item slime_layer = register(new BlockItem(UBlocks.slime_layer, new Item.Settings().group(ItemGroup.DECORATIONS)), "slime_layer");
public static final Item record_crusade = new URecord(Unicopia.MODID, "crusade", USounds.RECORD_CRUSADE);
public static final Item record_pet = new URecord(Unicopia.MODID, "pet", USounds.RECORD_PET);
public static final Item record_popular = new URecord(Unicopia.MODID, "popular", USounds.RECORD_POPULAR);
public static final Item record_funk = new URecord(Unicopia.MODID, "funk", USounds.RECORD_FUNK);
public static final Item mist_door = register(new TallBlockItem(UBlocks.mist_door, new Item.Settings().group(ItemGroup.REDSTONE)), "mist_door");
public static final Item library_door = register(new TallBlockItem(UBlocks.library_door, new Item.Settings().group(ItemGroup.REDSTONE)), "library_door");
public static final Item bakery_door = register(new TallBlockItem(UBlocks.bakery_door, new Item.Settings().group(ItemGroup.REDSTONE)), "bakery_door");
public static final Item diamond_door = register(new TallBlockItem(UBlocks.diamond_door, new Item.Settings().group(ItemGroup.REDSTONE)), "diamond_door");
public static final Item hive = new ItemBlock(UBlocks.hive).setRegistryName(Unicopia.MODID, "hive");
public static final Item chitin_shell = new Item()
.setCreativeTab(CreativeTabs.MATERIALS)
.setTranslationKey("chitin_shell")
.setRegistryName(Unicopia.MODID, "chitin_shell");
public static final Item chitin = new ItemBlock(UBlocks.chitin)
.setRegistryName(Unicopia.MODID, "chitin_block");
public static final Item chissled_chitin = new ItemBlock(UBlocks.chissled_chitin)
.setRegistryName(Unicopia.MODID, "chissled_chitin");
public static final Item cuccoon = new ItemBlock(UBlocks.cuccoon)
.setRegistryName(Unicopia.MODID, "cuccoon");
public static final Item slime_layer = new UnFuckedItemSnow(UBlocks.slime_layer)
.setRegistryName(Unicopia.MODID, "slime_layer");
public static final Item sugar_block = register(new BlockItem(UBlocks.sugar_block, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS)), "sugar_block");
public static final Item mist_door = new ItemDoor(UBlocks.mist_door)
.setTranslationKey("mist_door")
.setRegistryName(Unicopia.MODID, "mist_door");
public static final Item library_door = new ItemDoor(UBlocks.library_door)
.setTranslationKey("library_door")
.setRegistryName(Unicopia.MODID, "library_door");
public static final Item bakery_door = new ItemDoor(UBlocks.bakery_door)
.setTranslationKey("bakery_door")
.setRegistryName(Unicopia.MODID, "bakery_door");
public static final Item diamond_door = new ItemDoor(UBlocks.diamond_door)
.setTranslationKey("diamond_door")
.setRegistryName(Unicopia.MODID, "diamond_door");
public static final Item sugar_block = new UItemDecoration(UBlocks.sugar_block);
public static final Item cloud_slab = new UItemSlab(UBlocks.cloud_slab, UBlocks.cloud_slab.doubleSlab, INTERACT_WITH_CLOUDS);
public static final Item enchanted_cloud_slab = new UItemSlab(UBlocks.enchanted_cloud_slab, UBlocks.enchanted_cloud_slab.doubleSlab, INTERACT_WITH_CLOUDS);
public static final Item packed_cloud_slab = new UItemSlab(UBlocks.packed_cloud_slab, UBlocks.packed_cloud_slab.doubleSlab, INTERACT_WITH_CLOUDS);
public static final Item cloud_slab = new PredicatedBlockItem(UBlocks.cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
public static final Item enchanted_cloud_slab = new PredicatedBlockItem(UBlocks.enchanted_cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
public static final Item packed_cloud_slab = new PredicatedBlockItem(UBlocks.packed_cloud_slab, new Item.Settings().group(ItemGroup.BUILDING_BLOCKS), INTERACT_WITH_CLOUDS);
public static final ItemSpell spell = new ItemSpell(Unicopia.MODID, "gem");
public static final ItemSpell curse = new ItemCurse(Unicopia.MODID, "corrupted_gem");
public static final ItemOfHolding bag_of_holding = new ItemOfHolding(Unicopia.MODID, "bag_of_holding");
public static final ItemAlicornAmulet alicorn_amulet = Baubles.isModActive()
? Baubles.alicornAmulet() : new ItemAlicornAmulet(Unicopia.MODID, "alicorn_amulet");
public static final ItemAlicornAmulet alicorn_amulet = new ItemAlicornAmulet(Unicopia.MODID, "alicorn_amulet");
public static final ItemSpellbook spellbook = new ItemSpellbook(Unicopia.MODID, "spellbook");
public static final Item staff_meadow_brook = new ItemStaff(Unicopia.MODID, "staff_meadow_brook").setMaxDamage(2);
@ -167,10 +135,9 @@ public class UItems {
.setRegistryName(Unicopia.MODID, "alfalfa_seeds")
.setCreativeTab(CreativeTabs.MATERIALS);
public static final Item enchanted_torch = new ItemBlock(UBlocks.enchanted_torch)
.setRegistryName(Unicopia.MODID, "enchanted_torch");
public static final Item enchanted_torch = register(new BlockItem(UBlocks.enchanted_torch), "enchanted_torch");
public static final Item alfalfa_leaves = new ItemFood(1, 3, false)
public static final Item alfalfa_leaves = new FoodItem(1, 3, false)
.setTranslationKey("alfalfa_leaves")
.setRegistryName(Unicopia.MODID, "alfalfa_leaves");
@ -256,37 +223,6 @@ public class UItems {
.replace(Item.getItemFromBlock(Blocks.YELLOW_FLOWER), yellow_flower)
.replace(Item.getItemFromBlock(Blocks.RED_FLOWER), red_flower));
ItemRegistrar.registerAll(registry,
racing_cloud_spawner, construction_cloud_spawner, wild_cloud_spawner,
green_apple, sweet_apple, sour_apple,
zap_apple, rotten_apple, cooked_zap_apple,
apple_seeds, apple_leaves,
dew_drop, spear,
tomato, rotten_tomato,
cloudsdale_tomato, rotten_cloudsdale_tomato,
tomato_seeds, moss,
cloud_matter, cloud_block, enchanted_cloud, packed_cloud,
cloud_stairs,
cloud_slab, enchanted_cloud_slab, packed_cloud_slab,
cloud_fence, cloud_banister,
cloud_farmland, mist_door, library_door, bakery_door, diamond_door, anvil,
bag_of_holding, spell, curse, spellbook, mug, enchanted_torch,
staff_meadow_brook, staff_remembrance, alicorn_amulet,
alfalfa_seeds, alfalfa_leaves,
cereal, sugar_cereal, sugar_block,
hive, chitin_shell, chitin, chissled_chitin, cuccoon, slime_layer,
daffodil_daisy_sandwich, hay_burger, hay_fries, salad, wheat_worms,
apple_cider, juice, burned_juice,
record_crusade, record_pet, record_popular, record_funk);
if (UClient.isClientSide()) {
BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem"));
}
@ -302,32 +238,20 @@ public class UItems {
.done();
}
@SideOnly(Side.CLIENT)
private static <T extends Item> T register(T item, String namespace, String name) {
return Registry.ITEM.add(new Identifier(namespace, name), item);
}
private static <T extends Item> T register(T item, String name) {
return register(item, name);
}
static void registerColors(ItemColors registry) {
registry.registerItemColorHandler((stack, tint) -> {
registry.register((stack, tint) -> {
if (MAGI.test(MinecraftClient.getInstance().player)) {
return SpellRegistry.getInstance().getSpellTintFromStack(stack);
return SpellRegistry.instance().getSpellTintFromStack(stack);
}
return 0xffffff;
}, spell, curse);
}
public static class Shills {
private static final ItemStick stick = new ItemStick();
private static final ItemShear shears = new ItemShear();
@Nullable
public static Item getShill(Item itemIn) {
if (itemIn == Items.SHEARS) {
return shears;
}
if (itemIn == Items.STICK) {
return stick;
}
return null;
}
}
}

View file

@ -98,7 +98,7 @@ public class Unicopia implements IGuiHandler {
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object getServerGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) {
switch (ID) {
case 0: return new SpellBookContainer(player.inventory, world, new BlockPos(x, y, z));
default: return null;
@ -106,7 +106,7 @@ public class Unicopia implements IGuiHandler {
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
public Object getClientGuiElement(int ID, PlayerEntity player, World world, int x, int y, int z) {
switch (ID) {
case 0: return new GuiSpellBook(player);
default: return null;

View file

@ -48,8 +48,8 @@ public class UnicopiaClient extends UClient {
}
@Override
public void displayGuiToPlayer(EntityPlayer player, IInteractionObject inventory) {
if (player instanceof EntityPlayerSP) {
public void displayGuiToPlayer(PlayerEntity player, IInteractionObject inventory) {
if (player instanceof PlayerEntitySP) {
if ("unicopia:itemofholding".equals(inventory.getGuiID())) {
MinecraftClient.getInstance().displayGuiScreen(new GuiOfHolding(inventory));
}
@ -60,13 +60,13 @@ public class UnicopiaClient extends UClient {
@Override
@Nullable
public EntityPlayer getPlayer() {
public PlayerEntity getPlayer() {
return MinecraftClient.getInstance().player;
}
@Override
@Nullable
public EntityPlayer getPlayerByUUID(UUID playerId) {
public PlayerEntity getPlayerByUUID(UUID playerId) {
Minecraft mc = MinecraftClient.getInstance();
if (mc.player.getUniqueID().equals(playerId)) {
@ -78,12 +78,12 @@ public class UnicopiaClient extends UClient {
@Override
@Nonnull
public EntityPlayer createPlayer(Entity observer, GameProfile profile) {
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
return new EntityFakeClientPlayer(observer.world, profile);
}
@Override
public boolean isClientPlayer(@Nullable EntityPlayer player) {
public boolean isClientPlayer(@Nullable PlayerEntity player) {
if (getPlayer() == player) {
return true;
}
@ -102,8 +102,8 @@ public class UnicopiaClient extends UClient {
@Override
public void postRenderEntity(Entity entity) {
if (entity instanceof EntityPlayer) {
IPlayer iplayer = SpeciesList.instance().getPlayer((EntityPlayer)entity);
if (entity instanceof PlayerEntity) {
IPlayer iplayer = SpeciesList.instance().getPlayer((PlayerEntity)entity);
if (iplayer.getGravity().getGravitationConstant() < 0) {
GlStateManager.translate(0, entity.height, 0);
@ -121,8 +121,8 @@ public class UnicopiaClient extends UClient {
return true;
}
if (entity instanceof EntityPlayer) {
IPlayer iplayer = SpeciesList.instance().getPlayer((EntityPlayer)entity);
if (entity instanceof PlayerEntity) {
IPlayer iplayer = SpeciesList.instance().getPlayer((PlayerEntity)entity);
if (iplayer.getGravity().getGravitationConstant() < 0) {
GlStateManager.scale(1, -1, 1);

View file

@ -13,7 +13,7 @@ import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.ability.IPower;
import com.minelittlepony.unicopia.ability.Location;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.item.ItemApple;
import com.minelittlepony.unicopia.item.AppleItem;
import com.minelittlepony.unicopia.world.UWorld;
import com.minelittlepony.util.MagicalDamageSource;
import com.minelittlepony.util.PosHelper;
@ -367,7 +367,7 @@ public class PowerStomp implements IPower<PowerStomp.Data> {
}
private ItemStack getApple(World w, BlockState log) {
return ItemApple.getRandomItemStack(getVariant(log));
return AppleItem.getRandomItemStack(getVariant(log));
}
private int measureTree(World w, BlockState log, BlockPos pos) {

View file

@ -10,21 +10,20 @@ import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.item.ItemMoss;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockCloud extends Block implements ICloudBlock, ITillable {
@ -32,39 +31,32 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
private final CloudType variant;
public BlockCloud(Material material, CloudType variant, String domain, String name) {
super(material);
setRegistryName(domain, name);
setTranslationKey(name);
setCreativeTab(CreativeTabs.MATERIALS);
setHardness(0.5f);
setResistance(1.0F);
setSoundType(SoundType.CLOTH);
setLightOpacity(20);
setTickRandomly(true);
useNeighborBrightness = true;
super(FabricBlockSettings.of(material)
.strength(0.5F, 1)
.sounds(BlockSoundGroup.WOOL)
.ticksRandomly()
.build()
);
this.variant = variant;
}
@Override
public boolean isTranslucent(IBlockState state) {
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
return variant == CloudType.NORMAL;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
public boolean isOpaque(BlockState state) {
return variant != CloudType.NORMAL;
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) {
if (rand.nextInt(10) == 0) {
pos = pos.offset(EnumFacing.random(rand), 1 + rand.nextInt(2));
pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2));
state = world.getBlockState(pos);
IBlockState converted = ItemMoss.affected.getInverse().getConverted(state);
BlockState converted = ItemMoss.affected.getInverse().getConverted(state);
if (!state.equals(converted)) {
world.setBlockState(pos, converted);
@ -72,22 +64,6 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
}
}
@Override
//Push player out of block
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) {
return allowsFallingBlockToPass(state, world, pos);
}
@Override
public boolean isNormalCube(IBlockState state) {
return false;
}
@Override
public BlockRenderLayer getRenderLayer() {
return variant == CloudType.NORMAL ? BlockRenderLayer.TRANSLUCENT : super.getRenderLayer();
@ -95,8 +71,8 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
@Deprecated
@Override
public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) {
if (side == EnumFacing.UP && (variant == CloudType.ENCHANTED || world.getBlockState(pos.up()).getBlock() instanceof ICloudBlock)) {
public boolean isSideSolid(BlockState base_state, BlockView world, BlockPos pos, Direction side) {
if (side == Direction.UP && (variant == CloudType.ENCHANTED || world.getBlockState(pos.up()).getBlock() instanceof ICloudBlock)) {
return true;
}
@ -104,9 +80,9 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
}
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
public boolean doesSideBlockRendering(BlockState state, BlockView world, BlockPos pos, Direction face) {
IBlockState beside = world.getBlockState(pos.offset(face));
BlockState beside = world.getBlockState(pos.offset(face));
if (beside.getBlock() instanceof ICloudBlock) {
ICloudBlock cloud = ((ICloudBlock)beside.getBlock());
@ -134,19 +110,19 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
}
@Override
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
public void onEntityCollision(World w, BlockPos pos, BlockState state, Entity entity) {
if (!applyBouncyness(state, entity)) {
super.onEntityCollision(w, pos, state, entity);
}
}
@Override
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
public boolean canEntityDestroy(BlockState state, BlockView world, BlockPos pos, Entity entity) {
return getCanInteract(state, entity) && super.canEntityDestroy(state, world, pos, entity);
}
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
if (getCanInteract(state, entity)) {
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
}
@ -154,7 +130,7 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
@Deprecated
@Override
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
public float getPlayerRelativeBlockHardness(BlockState state, PlayerEntity player, World worldIn, BlockPos pos) {
if (CloudType.NORMAL.canInteract(player)) {
return super.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
}
@ -162,13 +138,13 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
}
@Override
public CloudType getCloudMaterialType(IBlockState blockState) {
public CloudType getCloudMaterialType(BlockState blockState) {
return variant;
}
@Deprecated
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
if (!handleRayTraceSpecialCases(worldIn, pos, blockState)) {
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
}
@ -176,13 +152,13 @@ public class BlockCloud extends Block implements ICloudBlock, ITillable {
}
@Override
public boolean canBeTilled(ItemStack hoe, EntityPlayer player, World world, IBlockState state, BlockPos pos) {
public boolean canBeTilled(ItemStack hoe, PlayerEntity player, World world, BlockState state, BlockPos pos) {
return SpeciesList.instance().getPlayer(player).getSpecies().canInteractWithClouds()
&& ITillable.super.canBeTilled(hoe, player, world, state, pos);
}
@Override
public IBlockState getFarmlandState(ItemStack hoe, EntityPlayer player, World world, IBlockState state, BlockPos pos) {
public BlockState getFarmlandState(ItemStack hoe, PlayerEntity player, World world, BlockState state, BlockPos pos) {
return UBlocks.cloud_farmland.getDefaultState();
}

View file

@ -8,26 +8,17 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.CloudType;
import com.minelittlepony.util.WorldEvent;
import net.minecraft.block.BlockAnvil;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.block.AnvilBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
public class BlockCloudAnvil extends AnvilBlock implements ICloudBlock {
public BlockCloudAnvil(String domain, String name) {
super();
@ -44,12 +35,12 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
}
@Override
public String getHarvestTool(IBlockState state) {
public String getHarvestTool(BlockState state) {
return "shovel";
}
@Override
public int getHarvestLevel(IBlockState state) {
public int getHarvestLevel(BlockState state) {
return 0;
}
@ -61,7 +52,7 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
}
@Override
public void onEndFalling(World world, BlockPos pos, IBlockState fallingState, IBlockState hitState) {
public void onEndFalling(World world, BlockPos pos, BlockState fallingState, BlockState hitState) {
WorldEvent.ENTITY_TAKEOFF.play(world, pos);
}
@ -71,7 +62,7 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, EnumHand hand, Direction facing, float hitX, float hitY, float hitZ) {
return false;
}
@ -88,13 +79,13 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
}
@Override
public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) {
public boolean isAir(BlockState state, BlockView world, BlockPos pos) {
return allowsFallingBlockToPass(state, world, pos);
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
IBlockState below = world.getBlockState(pos.down());
public void updateTick(World world, BlockPos pos, BlockState state, Random rand) {
BlockState below = world.getBlockState(pos.down());
if (below.getBlock() instanceof ICloudBlock) {
if (((ICloudBlock)below.getBlock()).isDense(below)) {
@ -106,14 +97,14 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
}
@Override
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
public void onEntityCollision(World w, BlockPos pos, BlockState state, Entity entity) {
if (!applyBouncyness(state, entity)) {
super.onEntityCollision(w, pos, state, entity);
}
}
@Override
public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player) {
public boolean canHarvestBlock(BlockView world, BlockPos pos, PlayerEntity player) {
return getCanInteract(world.getBlockState(pos), player);
}
@ -123,12 +114,12 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
}
@Override
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
public boolean canEntityDestroy(BlockState state, BlockView world, BlockPos pos, Entity entity) {
return getCanInteract(state, entity) && super.canEntityDestroy(state, world, pos, entity);
}
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
if (getCanInteract(state, entity)) {
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
}
@ -136,7 +127,7 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
@Deprecated
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
if (!handleRayTraceSpecialCases(worldIn, pos, blockState)) {
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
}
@ -145,7 +136,7 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
@Deprecated
@Override
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
public float getPlayerRelativeBlockHardness(BlockState state, PlayerEntity player, World worldIn, BlockPos pos) {
if (!CloudType.NORMAL.canInteract(player)) {
return -1;
}
@ -154,7 +145,7 @@ public class BlockCloudAnvil extends BlockAnvil implements ICloudBlock {
@Override
public CloudType getCloudMaterialType(IBlockState blockState) {
public CloudType getCloudMaterialType(BlockState blockState) {
return CloudType.NORMAL;
}
}

View file

@ -6,14 +6,12 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.CloudType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockCloudBanister extends BlockCloudFence {
@ -56,16 +54,16 @@ public class BlockCloudBanister extends BlockCloudFence {
}
@Override
public boolean canConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
IBlockState myState = world.getBlockState(pos);
public boolean canConnectTo(BlockView world, BlockPos pos, Direction facing) {
BlockState myState = world.getBlockState(pos);
return myState.getBlock() instanceof BlockCloudBanister
&& super.canConnectTo(world, pos, facing);
}
@Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
IBlockState state = world.getBlockState(pos.offset(facing));
public boolean canBeConnectedTo(BlockView world, BlockPos pos, Direction facing) {
BlockState state = world.getBlockState(pos.offset(facing));
return state.getBlock() instanceof BlockCloudBanister
&& state.getMaterial() == world.getBlockState(pos).getMaterial();
@ -73,7 +71,7 @@ public class BlockCloudBanister extends BlockCloudFence {
@Deprecated
@Override
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
public void addCollisionBoxToList(BlockState state, World world, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
if (!getCanInteract(state, entity)) {
return;
}
@ -100,38 +98,38 @@ public class BlockCloudBanister extends BlockCloudFence {
}
@Override
public boolean isTopSolid(IBlockState state) {
public boolean isTopSolid(BlockState state) {
return false;
}
@Override
public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos) {
public boolean canPlaceTorchOnTop(BlockState state, BlockView world, BlockPos pos) {
return false;
}
@Override
public Box getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
public Box getBoundingBox(BlockState state, BlockView source, BlockPos pos) {
state = state.getActualState(source, pos);
return BOUNDING_BOXES[getBoundingBoxIdx(state)];
}
public static int getBoundingBoxIdx(IBlockState state) {
public static int getBoundingBoxIdx(BlockState state) {
int i = 0;
if (state.getValue(NORTH)) {
i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
i |= 1 << Direction.NORTH.getHorizontalIndex();
}
if (state.getValue(EAST)) {
i |= 1 << EnumFacing.EAST.getHorizontalIndex();
i |= 1 << Direction.EAST.getHorizontalIndex();
}
if (state.getValue(SOUTH)) {
i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
i |= 1 << Direction.SOUTH.getHorizontalIndex();
}
if (state.getValue(WEST)) {
i |= 1 << EnumFacing.WEST.getHorizontalIndex();
i |= 1 << Direction.WEST.getHorizontalIndex();
}
return i;

View file

@ -7,15 +7,15 @@ import com.minelittlepony.unicopia.CloudType;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockCloudDoor extends UDoor implements ICloudBlock {
@ -29,12 +29,12 @@ public class BlockCloudDoor extends UDoor implements ICloudBlock {
}
@Override
public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
public MapColor getMapColor(BlockState state, BlockView worldIn, BlockPos pos) {
return blockMapColor;
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity player, EnumHand hand, Direction facing, float hitX, float hitY, float hitZ) {
if (!getCanInteract(state, player)) {
return false;
}
@ -43,18 +43,18 @@ public class BlockCloudDoor extends UDoor implements ICloudBlock {
}
@Override
public String getHarvestTool(IBlockState state) {
public String getHarvestTool(BlockState state) {
return "shovel";
}
@Override
public int getHarvestLevel(IBlockState state) {
public int getHarvestLevel(BlockState state) {
return 0;
}
@Deprecated
@Override
public float getBlockHardness(IBlockState blockState, World world, BlockPos pos) {
public float getBlockHardness(BlockState blockState, World world, BlockPos pos) {
float hardness = super.getBlockHardness(blockState, world, pos);
return Math.max(hardness, Math.min(60, hardness + (pos.getY() - 100)));
@ -66,20 +66,20 @@ public class BlockCloudDoor extends UDoor implements ICloudBlock {
}
@Override
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
public void onEntityCollision(World w, BlockPos pos, BlockState state, Entity entity) {
if (!applyBouncyness(state, entity)) {
super.onEntityCollision(w, pos, state, entity);
}
}
@Override
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
public boolean canEntityDestroy(BlockState state, BlockView world, BlockPos pos, Entity entity) {
return getCanInteract(state, entity) && super.canEntityDestroy(state, world, pos, entity);
}
@Deprecated
@Override
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
public float getPlayerRelativeBlockHardness(BlockState state, PlayerEntity player, World worldIn, BlockPos pos) {
if (CloudType.NORMAL.canInteract(player)) {
return super.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
}
@ -87,7 +87,7 @@ public class BlockCloudDoor extends UDoor implements ICloudBlock {
}
@Override
public CloudType getCloudMaterialType(IBlockState blockState) {
public CloudType getCloudMaterialType(BlockState blockState) {
return CloudType.NORMAL;
}
}

View file

@ -28,7 +28,7 @@ public class BlockCloudFarm extends UFarmland implements ICloudBlock {
}
@Override
public boolean isAir(BlockState state, IBlockAccess world, BlockPos pos) {
public boolean isAir(BlockState state, BlockView world, BlockPos pos) {
return allowsFallingBlockToPass(state, world, pos);
}
@ -81,7 +81,7 @@ public class BlockCloudFarm extends UFarmland implements ICloudBlock {
@Deprecated
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
if (!handleRayTraceSpecialCases(worldIn, pos, blockState)) {
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
}

View file

@ -35,32 +35,32 @@ public class BlockCloudFence extends FenceBlock implements ICloudBlock {
}
@Override
public boolean isTranslucent(IBlockState state) {
public boolean isTranslucent(BlockState state) {
return variant == CloudType.NORMAL;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
public boolean isOpaqueCube(BlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state) {
public boolean isFullCube(BlockState state) {
return false;
}
@Override
public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) {
public boolean isAir(BlockState state, BlockView world, BlockPos pos) {
return allowsFallingBlockToPass(state, world, pos);
}
@Override
public boolean isNormalCube(IBlockState state) {
public boolean isNormalCube(BlockState state) {
return false;
}
@Override
public CloudType getCloudMaterialType(IBlockState blockState) {
public CloudType getCloudMaterialType(BlockState blockState) {
return variant;
}
@ -83,8 +83,8 @@ public class BlockCloudFence extends FenceBlock implements ICloudBlock {
}
}
public boolean canConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) {
IBlockState myState = world.getBlockState(pos);
public boolean canConnectTo(BlockView world, BlockPos pos, Direction facing) {
BlockState myState = world.getBlockState(pos);
return !(myState.getBlock() instanceof BlockCloudBanister)
&& super.canConnectTo(world, pos, facing);
@ -98,12 +98,12 @@ public class BlockCloudFence extends FenceBlock implements ICloudBlock {
}
@Override
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
public boolean canEntityDestroy(BlockState state, BlockView world, BlockPos pos, Entity entity) {
return getCanInteract(state, entity) && super.canEntityDestroy(state, world, pos, entity);
}
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
if (getCanInteract(state, entity)) {
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, isActualState);
}
@ -120,7 +120,7 @@ public class BlockCloudFence extends FenceBlock implements ICloudBlock {
@Deprecated
@Override
public RayTraceResult collisionRayTrace(IBlockState state, World world, BlockPos pos, Vec3d start, Vec3d end) {
public RayTraceResult collisionRayTrace(BlockState state, World world, BlockPos pos, Vec3d start, Vec3d end) {
if (!handleRayTraceSpecialCases(world, pos, state)) {
return super.collisionRayTrace(state, world, pos, start, end);
}

View file

@ -48,7 +48,7 @@ public abstract class BlockCloudSlab<T extends Block & ICloudBlock> extends USla
@Deprecated
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
return null;
}
@ -124,9 +124,9 @@ public abstract class BlockCloudSlab<T extends Block & ICloudBlock> extends USla
}
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
public boolean doesSideBlockRendering(BlockState state, BlockView world, BlockPos pos, Direction face) {
IBlockState beside = world.getBlockState(pos.offset(face));
BlockState beside = world.getBlockState(pos.offset(face));
if (beside.getBlock() instanceof ICloudBlock) {
ICloudBlock cloud = ((ICloudBlock)beside.getBlock());
@ -140,7 +140,7 @@ public abstract class BlockCloudSlab<T extends Block & ICloudBlock> extends USla
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
public Item getItemDropped(BlockState state, Random rand, int fortune) {
return Item.getItemFromBlock(singleSlab);
}
}

View file

@ -5,42 +5,43 @@ import java.util.List;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.CloudType;
import com.minelittlepony.unicopia.forgebullshit.FUF;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.BlockSlab.EnumBlockHalf;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SlabBlock;
import net.minecraft.block.enums.BlockHalf;
import net.minecraft.block.enums.SlabType;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockCloudStairs extends UStairs implements ICloudBlock {
public BlockCloudStairs(IBlockState inherited, String domain, String name) {
public BlockCloudStairs(BlockState inherited, String domain, String name) {
super(inherited, domain, name);
}
@Override
public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) {
public boolean isAir(BlockState state, BlockView world, BlockPos pos) {
return allowsFallingBlockToPass(state, world, pos);
}
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
if (getCanInteract(theState, entity)) {
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean p_185477_7_) {
if (getCanInteract(baseBlockState, entity)) {
super.addCollisionBoxToList(state, worldIn, pos, entityBox, collidingBoxes, entity, p_185477_7_);
}
}
@Deprecated
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
public HitResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
if (handleRayTraceSpecialCases(worldIn, pos, blockState)) {
return null;
}
@ -49,61 +50,64 @@ public class BlockCloudStairs extends UStairs implements ICloudBlock {
@SuppressWarnings("deprecation")
@Override
public boolean isTopSolid(IBlockState state) {
public boolean isTopSolid(BlockState state) {
return getCloudMaterialType(state) == CloudType.ENCHANTED && super.isTopSolid(state);
}
@SuppressWarnings("deprecation")
@FUF(reason = "...Really?")
public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) {
public boolean isSideSolid(BlockState base_state, BlockView world, BlockPos pos, Direction side) {
return getCloudMaterialType(base_state) == CloudType.ENCHANTED && super.isSideSolid(base_state, world, pos, side);
}
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
state = state.getActualState(world, pos);
public boolean doesSideBlockRendering(BlockState state, BlockView world, BlockPos pos, Direction face) {
IBlockState beside = world.getBlockState(pos.offset(face)).getActualState(world, pos);
BlockState beside = world.getBlockState(pos.offset(face));
if (beside.getBlock() instanceof ICloudBlock) {
ICloudBlock cloud = ((ICloudBlock)beside.getBlock());
if (cloud.getCloudMaterialType(beside) == getCloudMaterialType(state)) {
EnumFacing front = state.getValue(FACING);
EnumHalf half = state.getValue(HALF);
Direction front = state.get(FACING);
BlockHalf half = state.get(HALF);
boolean sideIsBack = state.getBlockFaceShape(world, pos, face) == BlockFaceShape.SOLID;
boolean sideIsFront = state.getBlockFaceShape(world, pos, face.getOpposite()) == BlockFaceShape.SOLID;
VoxelShape shape = state.getCollisionShape(world, pos);
boolean sideIsBack = Block.isFaceFullSquare(shape, face);
boolean sideIsFront = Block.isFaceFullSquare(shape, face.getOpposite());
boolean sideIsSide = !(sideIsBack || sideIsFront);
if (beside.getBlock() == this) {
EnumFacing bfront = beside.getValue(FACING);
EnumHalf bhalf = beside.getValue(HALF);
Direction bfront = beside.get(FACING);
BlockHalf bhalf = beside.get(HALF);
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
if (face == Direction.UP || face == Direction.DOWN) {
return half != bhalf
&& ( (face == EnumFacing.UP && half == EnumHalf.TOP)
|| (face == EnumFacing.DOWN && half == EnumHalf.BOTTOM)
&& ( (face == Direction.UP && half == BlockHalf.TOP)
|| (face == Direction.DOWN && half == BlockHalf.BOTTOM)
);
}
boolean bsideIsBack = beside.getBlockFaceShape(world, pos, face) == BlockFaceShape.SOLID;
boolean bsideIsFront = beside.getBlockFaceShape(world, pos, face.getOpposite()) == BlockFaceShape.SOLID;
VoxelShape shapeBeside = beside.getCollisionShape(world, pos);
boolean bsideIsBack = Block.isFaceFullSquare(shapeBeside, face);
boolean bsideIsFront = Block.isFaceFullSquare(shapeBeside, face.getOpposite());
boolean bsideIsSide = !(bsideIsBack || bsideIsFront);
return sideIsBack
|| (sideIsSide && bsideIsSide && front == bfront && half == bhalf);
} else if (beside.getBlock() instanceof BlockCloudSlab) {
EnumBlockHalf bhalf = beside.getValue(BlockSlab.HALF);
SlabType bhalf = beside.get(SlabBlock.TYPE);
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
return bhalf == EnumBlockHalf.TOP && half == EnumHalf.BOTTOM;
if (face == Direction.UP || face == Direction.DOWN) {
return bhalf == SlabType.TOP && half == BlockHalf.BOTTOM;
}
return bhalf == EnumBlockHalf.TOP && half == EnumHalf.BOTTOM;
return bhalf == SlabType.TOP && half == BlockHalf.BOTTOM;
} else {
if (face == EnumFacing.UP || face == EnumFacing.DOWN) {
return half == EnumHalf.BOTTOM && face == EnumFacing.DOWN;
if (face == Direction.UP || face == Direction.DOWN) {
return half == BlockHalf.BOTTOM && face == Direction.DOWN;
}
}
@ -115,7 +119,7 @@ public class BlockCloudStairs extends UStairs implements ICloudBlock {
}
@Override
public CloudType getCloudMaterialType(IBlockState blockState) {
public CloudType getCloudMaterialType(BlockState blockState) {
return CloudType.NORMAL;
}
}

View file

@ -9,11 +9,11 @@ import com.minelittlepony.unicopia.Predicates;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.block.state.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockDiamondDoor extends UDoor {
@ -26,17 +26,17 @@ public class BlockDiamondDoor extends UDoor {
@Override
@Deprecated
public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
public MapColor getMapColor(BlockState state, BlockView worldIn, BlockPos pos) {
return MapColor.DIAMOND;
}
@Override
protected boolean canOpen(@Nullable EntityPlayer player) {
protected boolean canOpen(@Nullable PlayerEntity player) {
return Predicates.MAGI.test(player);
}
@Override
protected boolean onPowerStateChanged(World world, IBlockState state, BlockPos pos, boolean powered) {
protected boolean onPowerStateChanged(World world, BlockState state, BlockPos pos, boolean powered) {
if (state.getValue(OPEN)) {
world.setBlockState(pos, state.with(OPEN, false), 2);

View file

@ -4,11 +4,11 @@ import java.util.function.Supplier;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.item.Item;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class BlockDutchDoor extends UDoor {
@ -18,20 +18,20 @@ public class BlockDutchDoor extends UDoor {
}
@Override
protected BlockPos getPrimaryDoorPos(IBlockState state, BlockPos pos) {
protected BlockPos getPrimaryDoorPos(BlockState state, BlockPos pos) {
return pos;
}
@Override
public boolean isPassable(IBlockAccess world, BlockPos pos) {
public boolean isPassable(BlockView world, BlockPos pos) {
return world.getBlockState(pos).getValue(OPEN);
}
@Override
protected boolean onPowerStateChanged(World world, IBlockState state, BlockPos pos, boolean powered) {
protected boolean onPowerStateChanged(World world, BlockState state, BlockPos pos, boolean powered) {
boolean result = super.onPowerStateChanged(world, state, pos, powered);
IBlockState upper = world.getBlockState(pos.up());
BlockState upper = world.getBlockState(pos.up());
if (upper.getBlock() == this && upper.getValue(OPEN) != powered) {
world.setBlockState(pos.up(), upper.with(OPEN, powered));
@ -45,18 +45,18 @@ public class BlockDutchDoor extends UDoor {
// LOWER - HALF/FACING/FACING/OPEN
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
public BlockState getActualState(BlockState state, BlockView world, BlockPos pos) {
// copy properties in stored by the sibling block
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER) {
IBlockState other = world.getBlockState(pos.up());
BlockState other = world.getBlockState(pos.up());
if (other.getBlock() == this) {
return state.with(HINGE, other.getValue(HINGE))
.with(POWERED, other.getValue(POWERED));
}
} else {
IBlockState other = world.getBlockState(pos.down());
BlockState other = world.getBlockState(pos.down());
if (other.getBlock() == this) {
return state.with(FACING, other.getValue(FACING));
@ -68,10 +68,10 @@ public class BlockDutchDoor extends UDoor {
}
@Override
public IBlockState getStateFromMeta(int meta) {
public BlockState getStateFromMeta(int meta) {
boolean upper = (meta & 8) != 0;
IBlockState state = getDefaultState()
BlockState state = getDefaultState()
.with(HALF, upper ? EnumDoorHalf.UPPER : EnumDoorHalf.LOWER)
.with(OPEN, (meta & 4) != 0);
@ -80,11 +80,11 @@ public class BlockDutchDoor extends UDoor {
.with(HINGE, (meta & 2) != 0 ? EnumHingePosition.RIGHT : EnumHingePosition.LEFT);
}
return state.with(FACING, EnumFacing.byHorizontalIndex(meta & 3).rotateYCCW());
return state.with(FACING, Direction.byHorizontalIndex(meta & 3).rotateYCCW());
}
@Override
public int getMetaFromState(IBlockState state) {
public int getMetaFromState(BlockState state) {
int i = 0;
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER) {

View file

@ -56,7 +56,6 @@ public class BlockGrowingCuccoon extends Block {
setRegistryName(domain, name);
setResistance(0);
setSoundType(SoundType.SLIME);
setCreativeTab(CreativeTabs.MATERIALS);
setDefaultSlipperiness(0.5F);
setHarvestLevel("shovel", 2);
setLightLevel(0.6F);
@ -70,23 +69,23 @@ public class BlockGrowingCuccoon extends Block {
}
@Override
public boolean isTranslucent(IBlockState state) {
public boolean isTranslucent(BlockState state) {
return true;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
public boolean isOpaqueCube(BlockState state) {
return false;
}
@Override
//Push player out of block
public boolean isFullCube(IBlockState state) {
public boolean isFullCube(BlockState state) {
return false;
}
@Override
public boolean isNormalCube(IBlockState state) {
public boolean isNormalCube(BlockState state) {
return false;
}
@ -97,7 +96,7 @@ public class BlockGrowingCuccoon extends Block {
@Deprecated
@Override
public Box getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
public Box getCollisionBoundingBox(BlockState state, BlockView world, BlockPos pos) {
return getBoundingBox(state, world, pos);
}
@ -107,7 +106,7 @@ public class BlockGrowingCuccoon extends Block {
}
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
public void updateTick(World world, BlockPos pos, BlockState state, Random rand) {
if (!checkSupport(world, pos)) {
breakConnected(world, pos);
return;
@ -153,9 +152,9 @@ public class BlockGrowingCuccoon extends Block {
}
}
protected int getMaximumAge(World world, BlockPos pos, IBlockState state, boolean spaceBelow) {
protected int getMaximumAge(World world, BlockPos pos, BlockState state, boolean spaceBelow) {
if (state.get(SHAPE) == Shape.STRING) {
IBlockState higher = world.getBlockState(pos.up());
BlockState higher = world.getBlockState(pos.up());
if (higher.getBlock() != this) {
return 7;
@ -174,12 +173,12 @@ public class BlockGrowingCuccoon extends Block {
}
@Override
public int quantityDropped(IBlockState state, int fortune, Random random) {
public int quantityDropped(BlockState state, int fortune, Random random) {
return random.nextInt(3) == 0 ? state.get(AGE) : 0;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
public Item getItemDropped(BlockState state, Random rand, int fortune) {
return Items.SLIME_BALL;
}
@ -189,25 +188,25 @@ public class BlockGrowingCuccoon extends Block {
}
@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) {
public void onNeighborChange(BlockView world, BlockPos pos, BlockPos neighbor) {
if (world instanceof World && !checkSupport(world, pos)) {
breakConnected((World)world, pos);
}
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
public void breakBlock(World world, BlockPos pos, BlockState state) {
world.notifyNeighborsOfStateChange(pos, this, true);
super.breakBlock(world, pos, state);
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
public void onBlockAdded(World world, BlockPos pos, BlockState state) {
world.scheduleUpdate(pos, this, 10);
}
@Override
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity) {
public void onEntityCollision(World world, BlockPos pos, BlockState state, Entity entity) {
if (entity instanceof LivingEntity && !entity.isDead) {
LivingEntity living = (LivingEntity)entity;
@ -219,11 +218,11 @@ public class BlockGrowingCuccoon extends Block {
if (living.getHealth() <= 0) {
living.dropItem(Items.BONE, 3);
if (living instanceof EntityPlayer) {
if (living instanceof PlayerEntity) {
ItemStack skull = new ItemStack(Items.SKULL, 1);
if (world.rand.nextInt(13000) == 0) {
EntityPlayer player = (EntityPlayer)living;
PlayerEntity player = (PlayerEntity)living;
skull.setTagCompound(new NBTTagCompound());
skull.getTagCompound().setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), player.getGameProfile()));
@ -240,21 +239,21 @@ public class BlockGrowingCuccoon extends Block {
}
}
public boolean checkSupport(IBlockAccess world, BlockPos pos) {
public boolean checkSupport(BlockView world, BlockPos pos) {
if (PosHelper.some(pos, p -> !world.isAirBlock(p), EnumFacing.HORIZONTALS)) {
if (PosHelper.some(pos, p -> !world.isAirBlock(p), Direction.HORIZONTALS)) {
return false;
}
pos = pos.up();
IBlockState above = world.getBlockState(pos);
BlockState above = world.getBlockState(pos);
if (above.getBlock() == this || above.getBlock() == UBlocks.hive) {
return true;
}
switch (above.getBlockFaceShape(world, pos, EnumFacing.DOWN)) {
switch (above.getBlockFaceShape(world, pos, Direction.DOWN)) {
case SOLID:
case CENTER:
case CENTER_BIG:
@ -265,7 +264,7 @@ public class BlockGrowingCuccoon extends Block {
@Deprecated
@Override
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
public void addCollisionBoxToList(BlockState state, World world, BlockPos pos, Box entityBox, List<Box> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
if (!isActualState) {
state = state.getActualState(world, pos);
}
@ -283,7 +282,7 @@ public class BlockGrowingCuccoon extends Block {
@Deprecated
@Override
public Box getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
public Box getBoundingBox(BlockState state, BlockView source, BlockPos pos) {
state = state.getActualState(source, pos);
if (state.get(SHAPE) == Shape.BULB) {

View file

@ -23,7 +23,7 @@ import net.minecraft.world.BlockView;
public class ChiselledChitinBlock extends Block {
public ChiselledChitinBlock(String domain, String name) {
public ChiselledChitinBlock() {
super(FabricBlockSettings.of(UMaterials.hive)
.strength(50, 2000)
.materialColor(MaterialColor.BLACK)
@ -32,9 +32,6 @@ public class ChiselledChitinBlock extends Block {
setDefaultState(stateFactory.getDefaultState()
.with(Properties.FACING, Direction.UP)
);
// TODO:
// setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}
@Override

View file

@ -24,7 +24,7 @@ public class ChitinBlock extends Block {
public static final EnumProperty<Covering> COVERING = EnumProperty.of("covering", Covering.class);
public ChitinBlock(String domain, String name) {
public ChitinBlock() {
super(FabricBlockSettings.of(UMaterials.hive)
.hardness(50)
.strength(2000, 2000)

View file

@ -45,7 +45,7 @@ public class HiveWallBlock extends FallingBlock {
private static final IShape shape = new Sphere(false, 1.5);
public HiveWallBlock(String domain, String name) {
public HiveWallBlock() {
super(FabricBlockSettings.of(UMaterials.hive)
.noCollision()
.strength(10, 10)
@ -60,7 +60,6 @@ public class HiveWallBlock extends FallingBlock {
);
// TODO:
// setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
// setHarvestLevel("pickaxe", 1);
}

View file

@ -13,7 +13,7 @@ import net.minecraft.world.World;
public class SlimeLayerBlock extends SnowBlock {
public SlimeLayerBlock(String domain, String name) {
public SlimeLayerBlock() {
super(FabricBlockSettings.of(Material.CLAY)
.sounds(BlockSoundGroup.SLIME)
.materialColor(MaterialColor.GRASS)
@ -22,7 +22,6 @@ public class SlimeLayerBlock extends SnowBlock {
// TODO:
// drops Items.SLIME_BALL x1
// setCreativeTab(CreativeTabs.DECORATIONS);
}
@Override

View file

@ -30,7 +30,7 @@ public class StickBlock extends Block {
9/16F, 15/16F, 9/16F
));
public StickBlock(String domain, String name) {
public StickBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.noCollision()
.strength(0.2F, 0.2F)

View file

@ -6,14 +6,13 @@ import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup;
public class SugarBlock extends FallingBlock {
public SugarBlock(String domain, String name) {
public SugarBlock() {
super(FabricBlockSettings.of(Material.SAND)
.strength(10, 10)
.hardness(0.7F)
.sounds(BlockSoundGroup.SAND)
.build()
);
// setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
//TODO:
// Loot table drops:
// // Items.SUGAR x 9;

View file

@ -10,7 +10,7 @@ import net.minecraft.block.BlockPlanks;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@ -38,7 +38,7 @@ public class USapling extends BlockSapling implements ITreeGen {
}
@Override
public void generateTree(World world, BlockPos pos, IBlockState state, Random rand) {
public void generateTree(World world, BlockPos pos, BlockState state, Random rand) {
boolean massive = canGrowMassive();
@ -63,7 +63,7 @@ public class USapling extends BlockSapling implements ITreeGen {
items.add(new ItemStack(this));
}
protected void setSaplingsState(World world, IBlockState state, boolean massive, BlockPos pos) {
protected void setSaplingsState(World world, BlockState state, boolean massive, BlockPos pos) {
if (massive) {
world.setBlockState(pos , state, 4);
world.setBlockState(pos.add(1, 0, 0), state, 4);
@ -75,7 +75,7 @@ public class USapling extends BlockSapling implements ITreeGen {
}
@Override
public WorldGenAbstractTree getTreeGen(World world, IBlockState state, boolean massive) {
public WorldGenAbstractTree getTreeGen(World world, BlockState state, boolean massive) {
return treeGen.getTreeGen(world, state, massive);
}
@ -89,7 +89,7 @@ public class USapling extends BlockSapling implements ITreeGen {
* Returns null if no such spaces were found.
*/
@Nullable
public BlockPos findTwoByTwoSpace(World world, BlockPos pos, IBlockState state) {
public BlockPos findTwoByTwoSpace(World world, BlockPos pos, BlockState state) {
BlockPos xNegP = pos.add(-1, 0, 0);
BlockPos xPosP = pos.add( 1, 0, 0);
@ -125,7 +125,7 @@ public class USapling extends BlockSapling implements ITreeGen {
return null;
}
protected boolean isMatch(IBlockState state, IBlockState other) {
protected boolean isMatch(BlockState state, BlockState other) {
return other.getBlock() == this;
}
@ -136,17 +136,17 @@ public class USapling extends BlockSapling implements ITreeGen {
}
@Override
public int damageDropped(IBlockState state) {
public int damageDropped(BlockState state) {
return 0;
}
@Override
public IBlockState getStateFromMeta(int meta) {
public BlockState getStateFromMeta(int meta) {
return getDefaultState().with(STAGE, (meta & 8) >> 3);
}
@Override
public int getMetaFromState(IBlockState state) {
public int getMetaFromState(BlockState state) {
int i = 0;
i |= state.getValue(STAGE) << 3;
return i;

View file

@ -1,77 +1,53 @@
package com.minelittlepony.unicopia.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class UStairs extends BlockStairs {
public class UStairs extends StairsBlock {
protected Block theBlock;
protected IBlockState theState;
protected final Block baseBlock;
protected final BlockState baseBlockState;
@SuppressWarnings("deprecation")
public UStairs(IBlockState inherited, String domain, String name) {
super(inherited);
setTranslationKey(name);
setRegistryName(domain, name);
theBlock = inherited.getBlock();
theState = inherited;
setTickRandomly(theBlock.getTickRandomly());
useNeighborBrightness = true;
public UStairs(BlockState inherited, Block.Settings settings) {
super(inherited, settings);
baseBlock = inherited.getBlock();
baseBlockState = inherited;
}
@Override
@Deprecated
public boolean isTranslucent(IBlockState state) {
return theBlock.isTranslucent(state);
public boolean canSuffocate(BlockState state, BlockView world, BlockPos pos) {
return baseBlock.canSuffocate(baseBlockState, world, pos);
}
@Override
@Deprecated
public boolean isNormalCube(IBlockState state) {
return theBlock.isNormalCube(state);
public void onLandedUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
baseBlock.onLandedUpon(w, pos, entity, fallDistance);
}
@Override
public boolean isPassable(IBlockAccess worldIn, BlockPos pos) {
return theBlock.isPassable(worldIn, pos);
public void onEntityLand(BlockView w, Entity entity) {
baseBlock.onEntityLand(w, entity);
}
@Override
public void onFallenUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
theBlock.onFallenUpon(w, pos, entity, fallDistance);
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) {
baseBlockState.onEntityCollision(w, pos, entity);
}
@Override
public void onLanded(World w, Entity entity) {
theBlock.onLanded(w, entity);
}
@Override
public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) {
theBlock.onEntityCollision(w, pos, theState, entity);
}
@Override
public void onEntityWalk(World w, BlockPos pos, Entity entity) {
theBlock.onEntityWalk(w, pos, entity);
}
@Override
public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
return theBlock.canEntityDestroy(state, world, pos, entity);
public void onSteppedOn(World w, BlockPos pos, Entity entity) {
baseBlock.onSteppedOn(w, pos, entity);
}
@Deprecated
@Override
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos) {
return theBlock.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
return baseBlock.calcBlockBreakingDelta(state, player, world, pos);
}
}

View file

@ -9,7 +9,7 @@ import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
@ -33,7 +33,7 @@ class CommandGravity extends CommandBase {
throw new WrongUsageException(getUsage(sender));
}
EntityPlayer player = getCommandSenderAsPlayer(sender);
PlayerEntity player = getCommandSenderAsPlayer(sender);
IPlayer iplayer = SpeciesList.instance().getPlayer(player);

View file

@ -7,7 +7,7 @@ import net.minecraft.command.CommandException;
import net.minecraft.command.CommandGameMode;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
@ -24,7 +24,7 @@ class CommandOverrideGameMode extends CommandGameMode {
GameType gametype = getGameModeFromCommand(sender, params[0]);
EntityPlayer player = params.length >= 2 ? getPlayer(server, sender, params[1]) : getCommandSenderAsPlayer(sender);
PlayerEntity player = params.length >= 2 ? getPlayer(server, sender, params[1]) : getCommandSenderAsPlayer(sender);
updateGameMode(player, gametype);
@ -41,7 +41,7 @@ class CommandOverrideGameMode extends CommandGameMode {
}
}
protected void updateGameMode(EntityPlayer player, GameType m) {
protected void updateGameMode(PlayerEntity player, GameType m) {
player.setGameType(m);
IPlayer iplayer = SpeciesList.instance().getPlayer(player);

View file

@ -10,7 +10,7 @@ import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
@ -36,7 +36,7 @@ class CommandRacelist extends CommandBase {
throw new WrongUsageException(getUsage(sender));
}
EntityPlayer player = getCommandSenderAsPlayer(sender);
PlayerEntity player = getCommandSenderAsPlayer(sender);
Race race = Race.fromName(args[1], Race.EARTH);

View file

@ -10,7 +10,7 @@ import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
@ -81,7 +81,7 @@ class CommandSpecies extends CommandBase {
}
}
protected boolean updateSpecies(ICommandSender sender, EntityPlayer player, String[] args) {
protected boolean updateSpecies(ICommandSender sender, PlayerEntity player, String[] args) {
Race species = Race.fromName(args[1], Race.HUMAN);
if (species.isDefault()) {
@ -111,7 +111,7 @@ class CommandSpecies extends CommandBase {
return true;
}
protected boolean printSpecies(ICommandSender sender, EntityPlayer player) {
protected boolean printSpecies(ICommandSender sender, PlayerEntity player) {
Race spec = SpeciesList.instance().getPlayer(player).getSpecies();
String name = "commands.race.tell.";
@ -129,7 +129,7 @@ class CommandSpecies extends CommandBase {
return true;
}
protected boolean list(EntityPlayer player) {
protected boolean list(PlayerEntity player) {
player.sendMessage(new TextComponentTranslation("commands.race.list"));
ITextComponent message = new TextComponentString("");
@ -149,7 +149,7 @@ class CommandSpecies extends CommandBase {
return true;
}
protected boolean describeSpecies(EntityPlayer player, String[] args) {
protected boolean describeSpecies(PlayerEntity player, String[] args) {
Race species = Race.fromName(args[1], null);
if (species == null) {
@ -188,7 +188,7 @@ class CommandSpecies extends CommandBase {
if (args.length == 2 && (args[0].contentEquals("set") || args[0].contentEquals("describe"))) {
ArrayList<String> names = new ArrayList<String>();
EntityPlayer player = sender instanceof EntityPlayer ? (EntityPlayer)sender : null;
PlayerEntity player = sender instanceof PlayerEntity ? (PlayerEntity)sender : null;
for (Race i : Race.values()) {
if (args[0].contentEquals("describe") || (!i.isDefault() && SpeciesList.instance().speciesPermitted(i, player))) {

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.edibles;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
@ -28,7 +28,7 @@ public class BushToxicityDeterminent implements IEdible {
}
@Override
public void addSecondaryEffects(EntityPlayer player, Toxicity toxicity, ItemStack stack) {
public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
BlockDoublePlant.EnumPlantType type = getType(stack);
if ((type == ROSE || type == FERN)

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.edibles;
import net.minecraft.block.BlockFlower;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
@ -38,7 +38,7 @@ public class FlowerToxicityDeterminent implements IEdible {
}
@Override
public void addSecondaryEffects(EntityPlayer player, Toxicity toxicity, ItemStack stack) {
public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
BlockFlower.EnumFlowerType type = getType(stack);
if (type == HOUSTONIA && player.world.rand.nextInt(30) == 0) {

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.edibles;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@FunctionalInterface
@ -10,7 +10,7 @@ public interface IEdible {
Toxicity getToxicityLevel(ItemStack stack);
@Nonnull
default void addSecondaryEffects(EntityPlayer player, Toxicity toxicity, ItemStack stack) {
default void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
}
}

View file

@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.UEffects;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
@ -52,7 +52,7 @@ public abstract class ItemEdible extends ItemFood implements IEdible {
return useAction;
}
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
protected void onFoodEaten(ItemStack stack, World worldIn, PlayerEntity player) {
Race race = SpeciesList.instance().getPlayer(player).getSpecies();
Toxicity toxicity = (race.isDefault() || race == Race.CHANGELING) ? Toxicity.LETHAL : getToxicityLevel(stack);
@ -67,7 +67,7 @@ public abstract class ItemEdible extends ItemFood implements IEdible {
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) {
EntityPlayer entityplayer = entityLiving instanceof EntityPlayer ? (EntityPlayer)entityLiving : null;
PlayerEntity entityplayer = entityLiving instanceof PlayerEntity ? (PlayerEntity)entityLiving : null;
if (entityplayer != null) {
entityplayer.getFoodStats().addStats(this, stack);
@ -102,18 +102,18 @@ public abstract class ItemEdible extends ItemFood implements IEdible {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
Race race = SpeciesList.instance().getPlayer(player).getSpecies();
if (race.isDefault() || race == Race.CHANGELING) {
return new ActionResult<ItemStack>(EnumActionResult.FAIL, player.getStackInHand(hand));
return new TypedActionResult<ItemStack>(EnumActionResult.FAIL, player.getStackInHand(hand));
}
return super.onItemRightClick(world, player, hand);
}
@Override
public void addSecondaryEffects(EntityPlayer player, Toxicity toxicity, ItemStack stack) {
public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
if (toxicity.toxicWhenRaw()) {
player.addPotionEffect(toxicity.getPoisonEffect());

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.edibles;
import javax.annotation.Nonnull;
import com.minelittlepony.unicopia.forgebullshit.IMultiItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -31,7 +31,7 @@ public class MultiItemEdible extends ItemEdible implements IMultiItem {
}
@Override
public void addSecondaryEffects(EntityPlayer player, Toxicity toxicity, ItemStack stack) {
public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) {
super.addSecondaryEffects(player, toxicity, stack);
toxicityDeterminant.addSecondaryEffects(player, toxicity, stack);

View file

@ -1,10 +1,8 @@
package com.minelittlepony.unicopia.edibles;
import com.minelittlepony.util.lang.ServerLocale;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
public enum Toxicity {
SAFE(0, 0),
@ -47,10 +45,10 @@ public enum Toxicity {
return String.format("toxicity.%s.name", name().toLowerCase());
}
public String getTooltip() {
TextFormatting color = toxicWhenCooked() ? TextFormatting.RED : toxicWhenRaw() ? TextFormatting.DARK_PURPLE : TextFormatting.GRAY;
return color + ServerLocale.format(getTranslationKey());
public Text getTooltip() {
Text text = new TranslatableText(getTranslationKey());
text.getStyle().setColor(toxicWhenCooked() ? Formatting.RED : toxicWhenRaw() ? Formatting.DARK_PURPLE : Formatting.GRAY);
return text;
}
public static Toxicity byMetadata(int metadata) {

View file

@ -8,7 +8,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemMultiTexture;
@ -52,7 +52,7 @@ public class UItemFoodDelegate extends ItemMultiTexture implements IEdible {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
public TypedActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, EnumHand handIn) {
return foodItem.onItemRightClick(worldIn, playerIn, handIn);
}

View file

@ -146,7 +146,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
@Override
protected void collideWithEntity(Entity other) {
if (other instanceof EntityCloud || other instanceof EntityPlayer) {
if (other instanceof EntityCloud || other instanceof PlayerEntity) {
if (other.posY > posY) {
return;
}
@ -157,8 +157,8 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
@Override
public void applyEntityCollision(Entity other) {
if (other instanceof EntityPlayer) {
if (Predicates.INTERACT_WITH_CLOUDS.test((EntityPlayer)other)) {
if (other instanceof PlayerEntity) {
if (Predicates.INTERACT_WITH_CLOUDS.test((PlayerEntity)other)) {
super.applyEntityCollision(other);
}
} else if (other instanceof EntityCloud) {
@ -313,7 +313,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
}
@Override
public void onCollideWithPlayer(EntityPlayer player) {
public void onCollideWithPlayer(PlayerEntity player) {
if (player.posY >= posY) {
if (applyGravityCompensation(player)) {
double difX = player.posX - player.lastTickPosX;
@ -617,7 +617,7 @@ public class EntityCloud extends FlyingEntity implements ICloudEntity, IAnimals,
if (pos.getY() >= posY) {
while (world.isValid(pos)) {
pos = pos.down();
if (world.getBlockState(pos).isSideSolid(world, pos, EnumFacing.UP)) {
if (world.getBlockState(pos).isSideSolid(world, pos, Direction.UP)) {
return pos.up();
}
}

View file

@ -3,15 +3,15 @@ package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.Predicates;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.entity.PlayerEntitySP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
@ -36,7 +36,7 @@ public class EntityConstructionCloud extends EntityCloud {
}
@Override
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
if (!(isBeingRidden() || isRidingOrBeingRiddenBy(player)) && hand == EnumHand.MAIN_HAND) {
if (Predicates.INTERACT_WITH_CLOUDS.test(player)) {
@ -58,8 +58,8 @@ public class EntityConstructionCloud extends EntityCloud {
return EnumActionResult.FAIL;
}
private void placeBlock(EntityPlayer player, ItemStack stack, EnumHand hand) {
if (!world.isClient || !(player instanceof EntityPlayerSP)) {
private void placeBlock(PlayerEntity player, ItemStack stack, EnumHand hand) {
if (!world.isClient || !(player instanceof PlayerEntitySP)) {
return;
}
@ -84,14 +84,14 @@ public class EntityConstructionCloud extends EntityCloud {
return;
}
EnumFacing direction = trace.sideHit;
Direction direction = trace.sideHit;
BlockPos blockPos = new BlockPos(trace.hitVec);
mc.objectMouseOver = new RayTraceResult(trace.hitVec, direction, blockPos);
int oldCount = stack.getCount();
EnumActionResult result = mc.playerController.processRightClickBlock(((EntityPlayerSP)player), (WorldClient)player.world, blockPos, direction, trace.hitVec, hand);
EnumActionResult result = mc.playerController.processRightClickBlock(((PlayerEntitySP)player), (WorldClient)player.world, blockPos, direction, trace.hitVec, hand);
if (result == EnumActionResult.SUCCESS) {
player.swingArm(hand);

View file

@ -16,7 +16,7 @@ import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
@ -157,7 +157,7 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
}
@Override
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
if (hand == EnumHand.MAIN_HAND && Predicates.BUGGY.test(player)) {
@ -178,7 +178,7 @@ public class EntityCuccoon extends LivingEntity implements IMagicals, IInAnimate
}
}
if (passenger instanceof EntityPlayer) {
if (passenger instanceof PlayerEntity) {
if (!player.isPotionActive(MobEffects.HEALTH_BOOST)) {
player.addPotionEffect(new PotionEffect(MobEffects.HEALTH_BOOST, 13000, 1));
}

View file

@ -9,16 +9,16 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World;
public class EntityFakeClientPlayer extends AbstractClientPlayer implements IOwned<EntityPlayer> {
public class EntityFakeClientPlayer extends AbstractClientPlayer implements IOwned<PlayerEntity> {
private NetworkPlayerInfo playerInfo;
private EntityPlayer owner;
private PlayerEntity owner;
public EntityFakeClientPlayer(World world, GameProfile profile) {
super(world, profile);
@ -66,12 +66,12 @@ public class EntityFakeClientPlayer extends AbstractClientPlayer implements IOwn
}
@Override
public EntityPlayer getOwner() {
public PlayerEntity getOwner() {
return owner;
}
@Override
public void setOwner(EntityPlayer owner) {
public void setOwner(PlayerEntity owner) {
this.owner = owner;
}

View file

@ -3,15 +3,15 @@ package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.UClient;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
public class EntityFakeServerPlayer extends FakePlayer implements IOwned<EntityPlayer> {
public class EntityFakeServerPlayer extends FakePlayer implements IOwned<PlayerEntity> {
private EntityPlayer owner;
private PlayerEntity owner;
public EntityFakeServerPlayer(WorldServer world, GameProfile profile) {
super(world, profile);
@ -28,12 +28,12 @@ public class EntityFakeServerPlayer extends FakePlayer implements IOwned<EntityP
}
@Override
public EntityPlayer getOwner() {
public PlayerEntity getOwner() {
return owner;
}
@Override
public void setOwner(EntityPlayer owner) {
public void setOwner(PlayerEntity owner) {
this.owner = owner;
}

View file

@ -8,7 +8,7 @@ import com.minelittlepony.unicopia.Predicates;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.Vec3d;
@ -39,7 +39,7 @@ public class EntityRacingCloud extends EntityCloud {
}
@Override
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
if (!(isBeingRidden() || isRidingOrBeingRiddenBy(player)) && hand == EnumHand.MAIN_HAND) {
if (Predicates.INTERACT_WITH_CLOUDS.test(player)) {
if (!getStationary()) {

View file

@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Unicopia;
import net.minecraft.block.SoundType;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -150,7 +150,7 @@ public class EntitySpellbook extends EntityLiving implements IMagicals {
}
@Override
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand) {
public EnumActionResult applyPlayerInteraction(PlayerEntity player, Vec3d vec, EnumHand hand) {
if (player.isSneaking()) {
boolean open = !getIsOpen();

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.entity.item;
import java.util.UUID;
import com.minelittlepony.unicopia.entity.IMagicals;
import com.minelittlepony.unicopia.item.ITossableItem;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IMagicEffect;
@ -12,6 +11,7 @@ import com.minelittlepony.unicopia.magic.spells.SpellRegistry;
import com.minelittlepony.unicopia.network.EffectSync;
import com.minelittlepony.unicopia.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.projectile.ITossable;
import com.minelittlepony.unicopia.projectile.ITossableItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;

View file

@ -17,7 +17,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Slot;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.Identifier;
@ -33,7 +33,7 @@ public class GuiSpellBook extends GuiContainer implements IPageUnlockListener {
private PageButton nextPage;
private PageButton prevPage;
public GuiSpellBook(EntityPlayer player) {
public GuiSpellBook(PlayerEntity player) {
super(new SpellBookContainer(player.inventory, player.world, new BlockPos(player)));
player.openContainer = inventorySlots;

View file

@ -11,42 +11,46 @@ import com.minelittlepony.unicopia.edibles.Toxicity;
import com.minelittlepony.util.collection.Pool;
import com.minelittlepony.util.collection.Weighted;
import net.minecraft.block.BlockPlanks;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemFood;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.FoodComponents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.NonNullList;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.tag.BlockTags;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
public class ItemApple extends ItemFood implements IEdible {
public class AppleItem extends Item implements IEdible {
public static final Pool<Object, Weighted<Supplier<ItemStack>>> typeVariantMap = Pool.of(BlockPlanks.EnumType.OAK,
BlockPlanks.EnumType.OAK, new Weighted<Supplier<ItemStack>>()
private static final Pool<Object, Weighted<Supplier<ItemStack>>> typeVariantMap = Pool.of(PlanksBlock.Type.OAK,
PlanksBlock.Type.OAK, new Weighted<Supplier<ItemStack>>()
.put(1, () -> new ItemStack(UItems.rotten_apple))
.put(2, () -> new ItemStack(UItems.green_apple))
.put(3, () -> new ItemStack(UItems.red_apple)),
BlockPlanks.EnumType.SPRUCE, new Weighted<Supplier<ItemStack>>()
PlanksBlock.Type.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)),
BlockPlanks.EnumType.BIRCH, new Weighted<Supplier<ItemStack>>()
PlanksBlock.Type.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)),
BlockPlanks.EnumType.JUNGLE, new Weighted<Supplier<ItemStack>>()
PlanksBlock.Type.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)),
BlockPlanks.EnumType.ACACIA, new Weighted<Supplier<ItemStack>>()
PlanksBlock.Type.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)),
BlockPlanks.EnumType.DARK_OAK, new Weighted<Supplier<ItemStack>>()
PlanksBlock.Type.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)
@ -60,44 +64,40 @@ public class ItemApple extends ItemFood implements IEdible {
.orElse(ItemStack.EMPTY);
}
public ItemApple(String domain, String name) {
super(4, 3, false);
setTranslationKey(name);
if (!"minecraft".contentEquals(domain)) {
setRegistryName(domain, name);
}
public AppleItem(FoodComponent components) {
super(new Item.Settings()
.group(ItemGroup.FOOD)
.food(components));
}
@Override
public boolean onEntityItemUpdate(EntityItem item) {
public boolean onEntityItemUpdate(ItemEntity item) {
if (!item.isDead && item.ticksExisted > item.lifespan * 0.9) {
if (!item.removed && item.age > item.pickupDelay) {
if (!item.world.isClient) {
item.setDead();
item.remove();
EntityItem neu = new EntityItem(item.world);
neu.copyLocationAndAnglesFrom(item);
neu.setItem(new ItemStack(UItems.rotten_apple));
ItemEntity neu = EntityType.ITEM.create(item.world);
neu.copyPositionAndRotation(item);
neu.setStack(new ItemStack(UItems.rotten_apple));
item.world.spawnEntity(neu);
EntityItem copy = new EntityItem(item.world);
copy.copyLocationAndAnglesFrom(item);
copy.setItem(item.getItem());
copy.getItem().shrink(1);
ItemEntity copy = EntityType.ITEM.create(item.world);
copy.copyPositionAndRotation(item);
copy.setStack(item.getStack());
copy.getStack().decrement(1);
item.world.spawnEntity(copy);
} else {
float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + item.hoverStart) * 0.1F + 0.1F;
float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + item.hoverHeight) * 0.1F + 0.1F;
for (int i = 0; i < 3; i++) {
item.world.spawnParticle(EnumParticleTypes.SPELL_MOB, item.posX, item.posY + bob, item.posZ,
item.world.rand.nextGaussian() - 0.5F,
item.world.rand.nextGaussian() - 0.5F,
item.world.rand.nextGaussian() - 0.5F);
item.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, item.x, item.y + bob, item.z,
item.world.random.nextGaussian() - 0.5F,
item.world.random.nextGaussian() - 0.5F,
item.world.random.nextGaussian() - 0.5F);
}
}
}
@ -106,17 +106,7 @@ public class ItemApple extends ItemFood implements IEdible {
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this == UItems.red_apple && isInCreativeTab(tab)) {
items.add(new ItemStack(this));
items.add(new ItemStack(UItems.green_apple));
items.add(new ItemStack(UItems.sweet_apple));
items.add(new ItemStack(UItems.sour_apple));
}
}
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
public void appendTooltip(ItemStack stack, @Nullable World worldIn, List<Text> tooltip, TooltipContext context) {
tooltip.add(getToxicityLevel(stack).getTooltip());
}

View file

@ -0,0 +1,81 @@
package com.minelittlepony.unicopia.item;
import java.util.function.Function;
import com.minelittlepony.unicopia.entity.EntityCloud;
import com.minelittlepony.unicopia.magic.items.IDispensable;
import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Position;
import net.minecraft.world.RayTraceContext;
import net.minecraft.world.World;
public class CloudPlacerItem extends Item implements IDispensable {
private final Function<World, EntityCloud> cloudSupplier;
public CloudPlacerItem(Function<World, EntityCloud> cloudSupplier) {
super(new Item.Settings()
.group(ItemGroup.MATERIALS)
.maxCount(16)
);
this.cloudSupplier = cloudSupplier;
setDispenseable();
}
public void placeCloud(World world, BlockPos pos) {
EntityCloud cloud = cloudSupplier.apply(world);
cloud.setPositionAndAngles(pos, 0, 0);
world.spawnEntity(cloud);
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
ItemStack stack = player.getStackInHand(hand);
if (!world.isClient) {
HitResult mop = rayTrace(world, player, RayTraceContext.FluidHandling.NONE);
BlockPos pos;
if (mop.getType() == HitResult.Type.BLOCK) {
BlockHitResult bhr = (BlockHitResult)mop;
pos = bhr.getBlockPos().offset(bhr.getSide());
} else {
pos = player.getBlockPos();
}
placeCloud(world, pos);
if (!player.abilities.creativeMode) {
stack.decrement(1);
}
}
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
@Override
public TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
Position pos = DispenserBlock.getOutputLocation(source);
placeCloud(source.getWorld(), new BlockPos(pos.getX(), pos.getY(), pos.getZ()));
stack.decrement(1);
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
}

View file

@ -1,93 +0,0 @@
package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.item.AdvancedProjectileEntity;
import com.minelittlepony.unicopia.magic.items.IDispensable;
import com.minelittlepony.unicopia.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.projectile.ITossable;
import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IPosition;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
public interface ITossableItem extends ITossable<ItemStack>, IDispensable {
default boolean canBeThrown(ItemStack stack) {
return true;
}
@Override
default ActionResult<ItemStack> dispenseStack(IBlockSource source, ItemStack stack) {
if (canBeThrown(stack)) {
stack = toss(source.getWorld(), BlockDispenser.getDispensePosition(source), (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING), stack);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<>(EnumActionResult.PASS, stack);
}
@Nullable
default IAdvancedProjectile createProjectile(World world, EntityPlayer player) {
return new AdvancedProjectileEntity(world, player);
}
@Nullable
default IAdvancedProjectile createProjectile(World world, IPosition pos) {
return new AdvancedProjectileEntity(world, pos.getX(), pos.getY(), pos.getZ());
}
default void toss(World world, ItemStack itemstack, EntityPlayer player) {
world.playSound(null, player.posX, player.posY, player.posZ, getThrowSound(itemstack), SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
if (!world.isClient) {
IAdvancedProjectile projectile = createProjectile(world, player);
if (projectile == null) {
return;
}
projectile.setItem(itemstack);
projectile.setThrowDamage(getThrowDamage(itemstack));
projectile.launch(player, player.rotationPitch, player.rotationYaw, 0, 1.5F, 1);
world.spawnEntity((Entity)projectile);
}
if (!player.capabilities.isCreativeMode) {
itemstack.shrink(1);
}
player.addStat(StatList.getObjectUseStats(itemstack.getItem()));
}
default ItemStack toss(World world, IPosition pos, EnumFacing facing, ItemStack stack) {
IAdvancedProjectile projectile = createProjectile(world, pos);
if (projectile == null) {
return stack;
}
projectile.setItem(stack);
projectile.setThrowDamage(getThrowDamage(stack));
projectile.launch(facing.getXOffset(), facing.getYOffset() + 0.1F, facing.getZOffset(), 1.1F, 6);
world.spawnEntity((Entity)projectile);
stack.shrink(1);
return stack;
}
}

View file

@ -23,7 +23,7 @@ import net.minecraft.entity.MoverType;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
@ -89,15 +89,15 @@ public class ItemAlicornAmulet extends ItemArmor implements IDependable {
Vec3d position = entity.getPositionVector();
VecHelper.findAllEntitiesInRange(entity, world, entity.getPosition(), 10)
.filter(e -> e instanceof EntityPlayer)
.filter(e -> e instanceof PlayerEntity)
.sorted((a, b) -> (int)(a.getPositionVector().distanceTo(position) - b.getPositionVector().distanceTo(position)))
.findFirst()
.ifPresent(player -> interactWithPlayer(entity, (EntityPlayer)player));
.ifPresent(player -> interactWithPlayer(entity, (PlayerEntity)player));
return false;
}
protected void interactWithPlayer(EntityItem entity, EntityPlayer player) {
protected void interactWithPlayer(EntityItem entity, PlayerEntity player) {
double diffX = player.posX - entity.posX;
double diffY = player.posY - entity.posY;
double diffZ = player.posZ - entity.posZ;
@ -108,7 +108,7 @@ public class ItemAlicornAmulet extends ItemArmor implements IDependable {
if (player.getPositionVector().distanceTo(entity.getPositionVector()) < 3) {
if (entity.world.rand.nextInt(150) == 0) {
ActionResult<ItemStack> result = onItemRightClick(player.world, player, EnumHand.MAIN_HAND);
TypedActionResult<ItemStack> result = onItemRightClick(player.world, player, EnumHand.MAIN_HAND);
if (result.getType() == EnumActionResult.SUCCESS) {
entity.setPickupDelay(1000);
@ -150,7 +150,7 @@ public class ItemAlicornAmulet extends ItemArmor implements IDependable {
}
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
public void onArmorTick(World world, PlayerEntity player, ItemStack itemStack) {
if (player.getHealth() < player.getMaxHealth()) {
player.heal(0.5F);
} else if (player.canEat(false)) {

View file

@ -7,7 +7,7 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class ItemAppleMultiType extends ItemApple implements IMultiItem {
public class ItemAppleMultiType extends AppleItem implements IMultiItem {
private String[] subTypes = new String[0];

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.SpeciesList;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
@ -29,7 +29,7 @@ public class ItemCereal extends ItemFood {
}
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
protected void onFoodEaten(ItemStack stack, World worldIn, PlayerEntity player) {
super.onFoodEaten(stack, worldIn, player);
if (sugarAmount != 0) {

View file

@ -1,91 +0,0 @@
package com.minelittlepony.unicopia.item;
import java.util.function.Function;
import com.minelittlepony.unicopia.UItems;
import com.minelittlepony.unicopia.entity.EntityCloud;
import com.minelittlepony.unicopia.magic.items.IDispensable;
import net.minecraft.block.BlockDispenser;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IPosition;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class ItemCloudPlacer extends Item implements IDispensable {
private final Function<World, EntityCloud> cloudSupplier;
public ItemCloudPlacer(Function<World, EntityCloud> cloudSupplier, String domain, String name) {
super();
setTranslationKey(name);
setRegistryName(domain, name);
setCreativeTab(CreativeTabs.MATERIALS);
maxStackSize = 16;
this.cloudSupplier = cloudSupplier;
setDispenseable();
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this == UItems.racing_cloud_spawner && isInCreativeTab(tab)) {
items.add(new ItemStack(this));
items.add(new ItemStack(UItems.construction_cloud_spawner));
items.add(new ItemStack(UItems.wild_cloud_spawner));
}
}
public void placeCloud(World world, BlockPos pos) {
EntityCloud cloud = cloudSupplier.apply(world);
cloud.moveToBlockPosAndAngles(pos, 0, 0);
world.spawnEntity(cloud);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getStackInHand(hand);
if (!world.isClient) {
RayTraceResult mop = rayTrace(world, player, true);
BlockPos pos;
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
pos = mop.getBlockPos().offset(mop.sideHit);
} else {
pos = player.getPosition();
}
placeCloud(world, pos);
if (!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
@Override
public ActionResult<ItemStack> dispenseStack(IBlockSource source, ItemStack stack) {
IPosition pos = BlockDispenser.getDispensePosition(source);
placeCloud(source.getWorld(), new BlockPos(pos.getX(), pos.getY(), pos.getZ()));
stack.shrink(1);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
}

View file

@ -7,9 +7,9 @@ import com.minelittlepony.unicopia.spell.SpellCastResult;
import com.minelittlepony.util.MagicalDamageSource;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -41,7 +41,7 @@ public class ItemCurse extends ItemSpell {
}
@Override
public SpellCastResult onCastSpell(EntityPlayer player, World world, BlockPos pos, ItemStack stack, IMagicEffect effect, EnumFacing side, float hitX, float hitY, float hitZ) {
public SpellCastResult onCastSpell(PlayerEntity player, World world, BlockPos pos, ItemStack stack, IMagicEffect effect, Direction side, float hitX, float hitY, float hitZ) {
SpellCastResult result = super.onCastSpell(player, world, pos, stack, effect, side, hitX, hitY, hitZ);
if (result != SpellCastResult.NONE) {

View file

@ -8,6 +8,7 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.Predicates;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import com.minelittlepony.unicopia.projectile.ITossableItem;
import com.minelittlepony.unicopia.spell.CasterUtils;
import com.minelittlepony.unicopia.spell.IAligned;
import com.minelittlepony.unicopia.spell.ICaster;
@ -15,11 +16,11 @@ import com.minelittlepony.unicopia.spell.ITossedEffect;
import com.minelittlepony.unicopia.spell.SpellAffinity;
import com.minelittlepony.util.lang.ClientLocale;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
@ -51,13 +52,13 @@ public class ItemMagicStaff extends ItemStaff implements IAligned, ITossableItem
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
if (Predicates.MAGI.test(player) && hand == EnumHand.MAIN_HAND) {
ItemStack itemstack = player.getStackInHand(hand);
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
return new TypedActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
return super.onItemRightClick(world, player, hand);
@ -65,13 +66,13 @@ public class ItemMagicStaff extends ItemStaff implements IAligned, ITossableItem
@Override
public void onPlayerStoppedUsing(ItemStack itemstack, World world, LivingEntity entity, int timeLeft) {
if (Predicates.MAGI.test(entity) && entity instanceof EntityPlayer) {
if (Predicates.MAGI.test(entity) && entity instanceof PlayerEntity) {
int i = getMaxItemUseDuration(itemstack) - timeLeft;
if (i > 10) {
if (canBeThrown(itemstack)) {
toss(world, itemstack, (EntityPlayer)entity);
toss(world, itemstack, (PlayerEntity)entity);
}
}
}
@ -133,7 +134,7 @@ public class ItemMagicStaff extends ItemStaff implements IAligned, ITossableItem
}
@Override
public void toss(World world, ItemStack stack, EntityPlayer player) {
public void toss(World world, ItemStack stack, PlayerEntity player) {
IPlayer iplayer = SpeciesList.instance().getPlayer(player);
iplayer.subtractEnergyCost(4);
@ -143,7 +144,7 @@ public class ItemMagicStaff extends ItemStaff implements IAligned, ITossableItem
}
@Override
public void onImpact(ICaster<?> caster, BlockPos pos, IBlockState state) {
public void onImpact(ICaster<?> caster, BlockPos pos, BlockState state) {
effect.onImpact(caster, pos, state);
}

View file

@ -14,17 +14,17 @@ import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockSilverfish;
import net.minecraft.block.BlockStoneBrick;
import net.minecraft.block.BlockWall;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
@ -48,7 +48,7 @@ public class ItemMoss extends ItemEdible {
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING);
Direction facing = source.getBlockState().getValue(BlockDispenser.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
World w = source.getWorld();
@ -58,7 +58,7 @@ public class ItemMoss extends ItemEdible {
return stack;
}
EntityPlayer player = null;
PlayerEntity player = null;
for (LivingEntity e : w.getEntitiesWithinAABB(LivingEntity.class, Block.FULL_BLOCK_AABB.offset(pos), e ->
e instanceof IShearable && ((IShearable)e).isShearable(stack, w, pos)
@ -92,8 +92,8 @@ public class ItemMoss extends ItemEdible {
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.SHEARS, dispenserBehavior);
}
public boolean tryConvert(World world, IBlockState state, BlockPos pos, @Nullable EntityPlayer player) {
IBlockState converted = affected.getConverted(state);
public boolean tryConvert(World world, BlockState state, BlockPos pos, @Nullable PlayerEntity player) {
BlockState converted = affected.getConverted(state);
if (!state.equals(converted)) {
world.setBlockState(pos, converted, 3);

View file

@ -19,7 +19,7 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.Container;
@ -70,7 +70,7 @@ public class ItemOfHolding extends Item implements IMagicalItem {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
if (!Predicates.MAGI.test(player)) {
return super.onItemRightClick(world, player, hand);
@ -94,7 +94,7 @@ public class ItemOfHolding extends Item implements IMagicalItem {
inventory.writeTostack(stack);
inventory.closeInventory(player);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
return new TypedActionResult<>(EnumActionResult.SUCCESS, stack);
}
Box box = new Box(pos.offset(hit.sideHit)).grow(0.5);
@ -108,19 +108,19 @@ public class ItemOfHolding extends Item implements IMagicalItem {
inventory.writeTostack(stack);
inventory.closeInventory(player);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
return new TypedActionResult<>(EnumActionResult.SUCCESS, stack);
}
}
}
return new ActionResult<>(EnumActionResult.FAIL, stack);
return new TypedActionResult<>(EnumActionResult.FAIL, stack);
}
UClient.instance().displayGuiToPlayer(player, new Inventory(stack));
player.playSound(SoundEvents.BLOCK_ENDERCHEST_OPEN, 0.5F, 1);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
return new TypedActionResult<>(EnumActionResult.SUCCESS, stack);
}
@Override
@ -162,7 +162,7 @@ public class ItemOfHolding extends Item implements IMagicalItem {
}
@Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer player) {
public Container createContainer(InventoryPlayer playerInventory, PlayerEntity player) {
return new ContainerOfHolding(player);
}

View file

@ -1,14 +1,13 @@
package com.minelittlepony.unicopia.item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
public class ItemRottenApple extends ItemApple {
public class ItemRottenApple extends AppleItem {
public ItemRottenApple(String domain, String name) {
super(domain, name);
public ItemRottenApple(FoodComponent components) {
super(components);
}
@Override
@ -17,14 +16,7 @@ public class ItemRottenApple extends ItemApple {
}
@Override
public boolean onEntityItemUpdate(EntityItem item) {
public boolean onEntityItemUpdate(ItemEntity item) {
return false;
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (isInCreativeTab(tab)) {
items.add(new ItemStack(this));
}
}
}

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.projectile.ITossableItem;
import com.minelittlepony.unicopia.spell.ICaster;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.block.state.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
@ -24,25 +25,25 @@ public class ItemRottenTomato extends ItemTomato implements ITossableItem {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
ItemStack itemstack = player.getStackInHand(hand);
if (canBeThrown(itemstack) && !player.canEat(false)) {
toss(world, itemstack, player);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
return new TypedActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
return super.onItemRightClick(world, player, hand);
}
protected boolean isSickening(ItemStack stack, EntityPlayer player) {
protected boolean isSickening(ItemStack stack, PlayerEntity player) {
return canBeThrown(stack)
&& !SpeciesList.instance().getPlayer(player).getSpecies().canUseEarth();
}
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
protected void onFoodEaten(ItemStack stack, World worldIn, PlayerEntity player) {
if (isSickening(stack, player)) {
int duration = 7000;
@ -57,7 +58,7 @@ public class ItemRottenTomato extends ItemTomato implements ITossableItem {
}
@Override
public void onImpact(ICaster<?> caster, BlockPos pos, IBlockState state) {
public void onImpact(ICaster<?> caster, BlockPos pos, BlockState state) {
if (caster.isLocal() && state.getMaterial() == Material.GLASS) {
caster.getWorld().destroyBlock(pos, true);
}

View file

@ -3,20 +3,18 @@ package com.minelittlepony.unicopia.item;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.EntitySpear;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.projectile.IAdvancedProjectile;
import com.minelittlepony.unicopia.spell.ICaster;
import com.minelittlepony.unicopia.projectile.ITossableItem;
import net.minecraft.block.state.IBlockState;
import net.minecraft.dispenser.IPosition;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Position;
import net.minecraft.world.World;
public class ItemSpear extends Item implements ITossableItem {
@ -45,14 +43,14 @@ public class ItemSpear extends Item implements ITossableItem {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
if (!world.isClient) {
ItemStack itemstack = player.getStackInHand(hand);
if (canBeThrown(itemstack)) {
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
return new TypedActionResult<ItemStack>(EnumActionResult.SUCCESS, itemstack);
}
}
@ -62,14 +60,14 @@ public class ItemSpear extends Item implements ITossableItem {
@Override
public void onPlayerStoppedUsing(ItemStack itemstack, World world, LivingEntity entity, int timeLeft) {
if (entity instanceof EntityPlayer) {
if (entity instanceof PlayerEntity) {
int i = getMaxItemUseDuration(itemstack) - timeLeft;
if (i > 10) {
if (canBeThrown(itemstack)) {
itemstack.damageItem(1, entity);
toss(world, itemstack, (EntityPlayer)entity);
toss(world, itemstack, (PlayerEntity)entity);
}
}
}
@ -91,18 +89,18 @@ public class ItemSpear extends Item implements ITossableItem {
@Nullable
@Override
public IAdvancedProjectile createProjectile(World world, EntityPlayer player) {
public IAdvancedProjectile createProjectile(World world, PlayerEntity player) {
return new EntitySpear(world, player);
}
@Nullable
@Override
public IAdvancedProjectile createProjectile(World world, IPosition pos) {
public IAdvancedProjectile createProjectile(World world, Position pos) {
return null;
}
@Override
public void onImpact(ICaster<?> caster, BlockPos pos, IBlockState state) {
public void onImpact(ICaster<?> caster, BlockPos pos, BlockState state) {
}
}

View file

@ -21,14 +21,14 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
@ -47,7 +47,7 @@ public class ItemSpell extends Item implements ICastable {
setCreativeTab(CreativeTabs.BREWING);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, dispenserBehavior);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, DISPENSER_BEHAVIOUR);
}
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {
@ -66,14 +66,14 @@ public class ItemSpell extends Item implements ICastable {
@Override
public SpellCastResult onDispenseSpell(IBlockSource source, ItemStack stack, IDispenceable effect) {
EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING);
Direction facing = source.getBlockState().getValue(BlockDispenser.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
return effect.onDispenced(pos, facing, source, getAffinity(stack));
}
@Override
public SpellCastResult onCastSpell(EntityPlayer player, World world, BlockPos pos, ItemStack stack, IMagicEffect effect, EnumFacing side, float hitX, float hitY, float hitZ) {
public SpellCastResult onCastSpell(PlayerEntity player, World world, BlockPos pos, ItemStack stack, IMagicEffect effect, Direction side, float hitX, float hitY, float hitZ) {
if (effect instanceof IUseAction) {
return ((IUseAction)effect).onUse(stack, getAffinity(stack), player, world, pos, side, hitX, hitY, hitZ);
}
@ -82,7 +82,7 @@ public class ItemSpell extends Item implements ICastable {
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, EnumHand hand, Direction side, float hitX, float hitY, float hitZ) {
if (hand != EnumHand.MAIN_HAND || !Predicates.MAGI.test(player)) {
return EnumActionResult.PASS;
@ -122,16 +122,16 @@ public class ItemSpell extends Item implements ICastable {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
ItemStack stack = player.getStackInHand(hand);
if (!Predicates.MAGI.test(player)) {
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
return new TypedActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
if (!SpellRegistry.stackHasEnchantment(stack)) {
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
return new TypedActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
IUseAction effect = SpellRegistry.getInstance().getUseActionFrom(stack);
@ -144,11 +144,11 @@ public class ItemSpell extends Item implements ICastable {
stack.shrink(1);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
return new TypedActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
return new TypedActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
@Override

View file

@ -8,12 +8,12 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemBook;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
@ -21,7 +21,7 @@ public class ItemSpellbook extends ItemBook {
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDefaultDispenseItem() {
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
EnumFacing facing = source.getBlockState().getValue(BlockDispenser.FACING);
Direction facing = source.getBlockState().getValue(BlockDispenser.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
int yaw = 0;
@ -56,7 +56,7 @@ public class ItemSpellbook extends ItemBook {
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, dispenserBehavior);
}
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, EnumHand hand, Direction side, float hitX, float hitY, float hitZ) {
if (!world.isClient && Predicates.MAGI.test(player)) {
pos = pos.offset(side);

View file

@ -16,7 +16,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
@ -41,7 +41,7 @@ public class ItemStaff extends ItemSword {
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity target) {
public boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity target) {
World w = player.getEntityWorld();
for (int i = 0; i < 130; i++) {
@ -100,7 +100,7 @@ public class ItemStaff extends ItemSword {
if (slot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getAttackDamage(), 0));
multimap.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(ATTACK_REACH_MODIFIER, "Weapon modifier", 3, 0));
multimap.put(PlayerEntity.REACH_DISTANCE.getName(), new AttributeModifier(ATTACK_REACH_MODIFIER, "Weapon modifier", 3, 0));
}
return multimap;

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.UItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
@ -32,7 +32,7 @@ public class ItemTomato extends ItemFood {
}
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
protected void onFoodEaten(ItemStack stack, World worldIn, PlayerEntity player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.NAUSEA);

View file

@ -4,12 +4,12 @@ import com.minelittlepony.unicopia.UBlocks;
import com.minelittlepony.unicopia.block.StickBlock;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -23,9 +23,9 @@ public class ItemTomatoSeeds extends Item {
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, EnumHand hand, Direction facing, float hitX, float hitY, float hitZ) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
Block block = state.getBlock();

View file

@ -5,20 +5,11 @@ import com.minelittlepony.unicopia.edibles.Toxicity;
import com.minelittlepony.util.MagicalDamageSource;
import com.minelittlepony.util.VecHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.entity.LightningEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.DefaultedList;
import net.minecraft.world.World;
public class ItemZapApple extends ItemAppleMultiType {
@ -29,7 +20,7 @@ public class ItemZapApple extends ItemAppleMultiType {
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
public TypedActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
RayTraceResult mop = VecHelper.getObjectMouseOver(player, 5, 0);
if (mop != null && mop.typeOfHit == RayTraceResult.Type.ENTITY) {
@ -44,7 +35,7 @@ public class ItemZapApple extends ItemAppleMultiType {
}
@Override
protected void onFoodEaten(ItemStack stack, World w, EntityPlayer player) {
protected void onFoodEaten(ItemStack stack, World w, PlayerEntity player) {
super.onFoodEaten(stack, w, player);
player.attackEntityFrom(MagicalDamageSource.create("zap"), 120);
@ -58,18 +49,18 @@ public class ItemZapApple extends ItemAppleMultiType {
|| e instanceof EntityPig;
}
public ActionResult<ItemStack> onFedTo(ItemStack stack, EntityPlayer player, Entity e) {
e.onStruckByLightning(new EntityLightningBolt(e.world, e.posX, e.posY, e.posZ, false));
public TypedActionResult<ItemStack> onFedTo(ItemStack stack, PlayerEntity player, Entity e) {
e.onStruckByLightning(new LightningEntity(e.world, e.posX, e.posY, e.posZ, false));
if (!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
return new TypedActionResult<ItemStack>(ActionResult.SUCCESS, stack);
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
public void getSubItems(CreativeTabs tab, DefaultedList<ItemStack> items) {
if (isInCreativeTab(tab)) {
items.add(new ItemStack(this, 1, 0));
}

View file

@ -0,0 +1,40 @@
package com.minelittlepony.unicopia.item;
import java.util.function.Predicate;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class PredicatedBlockItem extends BlockItem {
private final Predicate<PlayerEntity> abilityTest;
public PredicatedBlockItem(Block block, Item.Settings settings, Predicate<PlayerEntity> abilityTest) {
super(block, settings);
this.abilityTest = abilityTest;
}
@Override
protected boolean canPlace(ItemPlacementContext context, BlockState state) {
if (context.getPlayer() != null && !(context.getPlayer().abilities.creativeMode || abilityTest.test(context.getPlayer()))) {
return false;
}
return super.canPlace(context, state);
}
@Override
public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity player) {
if (!(player.abilities.creativeMode || abilityTest.test(player))) {
return false;
}
return super.canMine(state, world, pos, player);
}
}

View file

@ -1,45 +0,0 @@
package com.minelittlepony.unicopia.item;
import java.util.function.Predicate;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class UItemBlock extends UItemDecoration {
private final Predicate<EntityPlayer> abilityTest;
public UItemBlock(Block block, Predicate<EntityPlayer> abilityTest) {
super(block);
this.abilityTest = abilityTest;
}
public UItemBlock(Block block, Identifier res, Predicate<EntityPlayer> abilityTest) {
super(block, res);
this.abilityTest = abilityTest;
}
public UItemBlock(Block block, String domain, String name, Predicate<EntityPlayer> abilityTest) {
super(block, domain, name);
this.abilityTest = abilityTest;
}
@Override
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
if (!(player.capabilities.isCreativeMode || abilityTest.test(player))) {
return false;
}
return super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
}
}

View file

@ -1,24 +0,0 @@
package com.minelittlepony.unicopia.item;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.Identifier;
public class UItemDecoration extends ItemBlock {
public UItemDecoration(Block block) {
this(block, block.getRegistryName());
}
public UItemDecoration(Block block, String domain, String name) {
this(block, new Identifier(domain, name));
}
public UItemDecoration(Block block, Identifier res) {
super(block);
setTranslationKey(res.getPath());
setRegistryName(res);
setCreativeTab(block.getCreativeTab());
}
}

View file

@ -1,33 +0,0 @@
package com.minelittlepony.unicopia.item;
import java.util.function.Predicate;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemMultiTexture;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class UItemMultiTexture extends ItemMultiTexture {
private final Predicate<EntityPlayer> abilityTest;
public UItemMultiTexture(Block block, ItemMultiTexture.Mapper mapper, Predicate<EntityPlayer> abilityTest) {
super(block, block, mapper);
this.setRegistryName(block.getRegistryName());
this.abilityTest = abilityTest;
}
@Override
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
if (!(player.capabilities.isCreativeMode || abilityTest.test(player))) {
return false;
}
return super.canPlaceBlockOnSide(worldIn, pos, side, player, stack);
}
}

View file

@ -1,34 +0,0 @@
package com.minelittlepony.unicopia.item;
import java.util.function.Predicate;
import net.minecraft.block.BlockSlab;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemSlab;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class UItemSlab extends ItemSlab {
private final Predicate<EntityPlayer> abilityTest;
public UItemSlab(BlockSlab singleSlab, BlockSlab doubleSlab, Predicate<EntityPlayer> abilityTest) {
super(singleSlab, singleSlab, doubleSlab);
this.abilityTest = abilityTest;
setHasSubtypes(false);
setRegistryName(singleSlab.getRegistryName());
setTranslationKey(singleSlab.getRegistryName().getPath());
}
@Override
public boolean canPlaceBlockOnSide(World world, BlockPos origin, EnumFacing side, EntityPlayer player, ItemStack stack) {
if (!(player.capabilities.isCreativeMode || abilityTest.test(player))) {
return false;
}
return super.canPlaceBlockOnSide(world, origin, side, player, stack);
}
}

View file

@ -1,14 +1,18 @@
package com.minelittlepony.unicopia.item;
import net.minecraft.item.ItemRecord;
import net.minecraft.util.SoundEvent;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.MusicDiscItem;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Rarity;
public class URecord extends MusicDiscItem {
public class URecord extends ItemRecord {
public URecord(String domain, String name, SoundEvent sound) {
super(name, sound);
setTranslationKey("record");
setRegistryName(domain, "record_" + name);
public URecord(SoundEvent sound) {
super(1, sound, new Item.Settings()
.maxCount(1)
.group(ItemGroup.MISC)
.rarity(Rarity.RARE)
);
}
}

View file

@ -2,20 +2,16 @@ package com.minelittlepony.unicopia.item.override;
import com.minelittlepony.unicopia.UItems;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemShears;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.item.ShearsItem;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ItemShear extends ItemShears {
public class ItemShear extends ShearsItem {
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState state = world.getBlockState(pos);
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, EnumHand hand, Direction facing, float hitX, float hitY, float hitZ) {
BlockState state = world.getBlockState(pos);
if (UItems.moss.tryConvert(world, state, pos, player)) {
ItemStack stack = player.getStackInHand(hand);

View file

@ -1,46 +1,58 @@
package com.minelittlepony.unicopia.item.override;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.UBlocks;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.advancement.criterion.Criterions;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
public class ItemStick extends Item {
public ItemStick(Settings settings) {
super(settings);
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack itemstack = player.getStackInHand(hand);
IBlockState state = worldIn.getBlockState(pos);
public ActionResult useOnBlock(ItemUsageContext context) {
if (facing == EnumFacing.UP && player.canPlayerEdit(pos.offset(facing), facing, itemstack) && worldIn.isAirBlock(pos.up())) {
World world = context.getWorld();
BlockPos pos = context.getBlockPos();
Direction facing = context.getSide();
worldIn.setBlockState(pos.up(), UBlocks.stick.getDefaultState());
@Nullable
PlayerEntity player = context.getPlayer();
SoundType sound = state.getBlock().getSoundType(state, worldIn, pos, player);
if (facing == Direction.UP && world.isAir(pos.up()) && (player == null || world.canPlayerModifyAt(player, pos.offset(facing)))) {
worldIn.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1) / 2, sound.getPitch());
world.setBlockState(pos.up(), UBlocks.stick.getDefaultState());
BlockSoundGroup sound = world.getBlockState(pos).getSoundGroup();
world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1) / 2, sound.getPitch());
ItemStack itemstack = context.getStack();
if (player instanceof ServerPlayerEntity) {
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack);
Criterions.PLACED_BLOCK.handle((ServerPlayerEntity)player, pos.up(), itemstack);
}
if (!(player instanceof EntityPlayer && ((EntityPlayer)player).capabilities.isCreativeMode)) {
itemstack.shrink(1);
if (player == null || !player.abilities.creativeMode) {
itemstack.decrement(1);
}
return EnumActionResult.SUCCESS;
return ActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
return ActionResult.FAIL;
}
}

View file

@ -16,17 +16,17 @@ import net.minecraft.world.World;
public interface ICastable extends IMagicalItem, IDispensable {
@Override
default ActionResult<ItemStack> dispenseStack(IBlockSource source, ItemStack stack) {
default TypedActionResult<ItemStack> dispenseStack(IBlockSource source, ItemStack stack) {
IDispenceable effect = SpellRegistry.instance().getDispenseActionFrom(stack);
if (effect == null) {
return new ActionResult<>(ActionResult.FAIL, stack);
return new TypedActionResult<>(ActionResult.FAIL, stack);
}
SpellCastResult dispenceResult = onDispenseSpell(source, stack, effect);
if (dispenceResult == SpellCastResult.DEFAULT) {
return new ActionResult<>(ActionResult.PASS, stack);
return new TypedActionResult<>(ActionResult.PASS, stack);
}
if (dispenceResult == SpellCastResult.PLACE) {

View file

@ -1,40 +1,36 @@
package com.minelittlepony.unicopia.magic.items;
import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.dispenser.ItemDispenserBehavior;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPointer;
public interface IDispensable {
IBehaviorDispenseItem dispenserBehavior = new BehaviorDefaultDispenseItem() {
@Override
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
ActionResult<ItemStack> result = ((IDispensable)stack.getItem()).dispenseStack(source, stack);
if (result.getType() != EnumActionResult.SUCCESS) {
return super.dispense(source, stack);
}
return result.getResult();
}
};
/**
* Enables dispensing behaviours for this item.
*/
default Item setDispenseable() {
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject((Item)(Object)this, dispenserBehavior);
DispenserBlock.registerBehavior((Item)this, new ItemDispenserBehavior() {
@Override
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack) {
TypedActionResult<ItemStack> result = dispenseStack(source, stack);
return (Item)(Object)this;
if (result.getResult() != ActionResult.SUCCESS) {
return super.dispense(source, stack);
}
return result.getValue();
}
});
return (Item)this;
}
/**
* Called to dispense this stack.
*/
ActionResult<ItemStack> dispenseStack(IBlockSource source, ItemStack stack);
TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack);
}

View file

@ -26,18 +26,18 @@ import net.minecraft.block.BlockSilverfish;
import net.minecraft.block.BlockStoneBrick;
import net.minecraft.block.BlockWall;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
@ -98,7 +98,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ) {
boolean result = false;
if (player == null || player.isSneaking()) {
@ -118,7 +118,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, @Nullable Entity hitEntity) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, @Nullable Entity hitEntity) {
if (hitEntity == null) {
return SpellCastResult.NONE;
}
@ -127,7 +127,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
}
@Override
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, Affinity affinity) {
public SpellCastResult onDispenced(BlockPos pos, Direction facing, IBlockSource source, Affinity affinity) {
pos = pos.offset(facing, 4);
boolean result = false;
@ -144,7 +144,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
}
protected boolean applyBlocks(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
Block id = state.getBlock();
if (id != Blocks.AIR) {
@ -183,7 +183,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
return true;
}
} else {
IBlockState newState = affected.getConverted(state);
BlockState newState = affected.getConverted(state);
if (!state.equals(newState)) {
world.setBlockState(pos, newState, 3);
@ -206,7 +206,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
protected boolean applyEntitySingle(Entity owner, World world, Entity e) {
if ((!e.equals(owner) ||
(owner instanceof EntityPlayer && !Predicates.MAGI.test(owner))) && !(e instanceof EntityItem)
(owner instanceof PlayerEntity && !Predicates.MAGI.test(owner))) && !(e instanceof EntityItem)
&& !(e instanceof IMagicals)) {
e.setFire(60);
e.attackEntityFrom(getDamageCause(e, (LivingEntity)owner), 0.1f);
@ -225,7 +225,7 @@ public class SpellFire extends AbstractSpell.RangedAreaSpell implements IUseable
* Transmists power to a piece of redstone
*/
private void sendPower(World w, BlockPos pos, int power, int max, int i) {
IBlockState state = w.getBlockState(pos);
BlockState state = w.getBlockState(pos);
Block id = state.getBlock();
if (i < max && id == Blocks.REDSTONE_WIRE) {

View file

@ -5,7 +5,7 @@ import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.ICaster;
import com.minelittlepony.unicopia.magic.IHeldEffect;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.DamageSource;
@ -37,7 +37,7 @@ public class SpellFlame extends AbstractSpell implements IHeldEffect {
@Override
public void updateInHand(IPlayer caster, Affinity affinity) {
EntityPlayer player = caster.getOwner();
PlayerEntity player = caster.getOwner();
if (player.ticksExisted % 15 == 0) {
player.attackEntityFrom(DamageSource.ON_FIRE, 1);

View file

@ -21,15 +21,15 @@ import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.BlockSnow;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
@ -86,12 +86,12 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseable,
}
@Override
public SpellCastResult onDispenced(BlockPos pos, EnumFacing facing, IBlockSource source, Affinity affinity) {
public SpellCastResult onDispenced(BlockPos pos, Direction facing, IBlockSource source, Affinity affinity) {
return applyBlocks(null, source.getWorld(), pos.offset(facing, rad)) ? SpellCastResult.NONE : SpellCastResult.DEFAULT;
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ) {
if (player != null && player.isSneaking()) {
applyBlockSingle(world, pos);
} else {
@ -102,7 +102,7 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseable,
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, @Nullable Entity hitEntity) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, @Nullable Entity hitEntity) {
if (hitEntity != null && applyEntitySingle(player, hitEntity)) {
return SpellCastResult.DEFAULT;
}
@ -110,7 +110,7 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseable,
return SpellCastResult.NONE;
}
private boolean applyBlocks(EntityPlayer owner, World world, BlockPos pos) {
private boolean applyBlocks(PlayerEntity owner, World world, BlockPos pos) {
for (BlockPos i : PosHelper.getAllInRegionMutable(pos, effect_range)) {
applyBlockSingle(world, i);
@ -119,13 +119,13 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseable,
return applyEntities(owner, world, pos);
}
protected boolean applyEntities(EntityPlayer owner, World world, BlockPos pos) {
protected boolean applyEntities(PlayerEntity owner, World world, BlockPos pos) {
return VecHelper.findAllEntitiesInRange(owner, world, pos, 3).filter(i ->
applyEntitySingle(owner, i)
).count() > 0;
}
protected boolean applyEntitySingle(EntityPlayer owner, Entity e) {
protected boolean applyEntitySingle(PlayerEntity owner, Entity e) {
if (e instanceof EntityTNTPrimed) {
e.setDead();
e.getEntityWorld().setBlockState(e.getPosition(), Blocks.TNT.getDefaultState());
@ -139,14 +139,14 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseable,
}
private void applyBlockSingle(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
Block id = state.getBlock();
IBlockState converted = affected.getConverted(state);
BlockState converted = affected.getConverted(state);
if (!state.equals(converted)) {
world.setBlockState(pos, converted, 3);
} else if (state.getMaterial() != UMaterials.cloud && state.isSideSolid(world, pos, EnumFacing.UP)
} else if (state.getMaterial() != UMaterials.cloud && state.isSideSolid(world, pos, Direction.UP)
|| (id == Blocks.SNOW)
|| (id instanceof BlockLeaves)) {
incrementIce(world, pos.up());
@ -166,7 +166,7 @@ public class SpellIce extends AbstractSpell.RangedAreaSpell implements IUseable,
}
private void incrementIce(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
Block id = state.getBlock();
if (id == Blocks.AIR || (id instanceof BlockBush)) {

View file

@ -11,14 +11,14 @@ import com.minelittlepony.util.shape.Sphere;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockOre;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@ -64,7 +64,7 @@ public class SpellInferno extends SpellFire {
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ) {
return SpellCastResult.PLACE;
}
@ -81,8 +81,8 @@ public class SpellInferno extends SpellFire {
for (int i = 0; i < radius; i++) {
BlockPos pos = new BlockPos(shape.computePoint(w.rand).add(origin));
IBlockState state = w.getBlockState(pos);
IBlockState newState = hellFireAffected.getConverted(state);
BlockState state = w.getBlockState(pos);
BlockState newState = hellFireAffected.getConverted(state);
if (!state.equals(newState)) {
w.setBlockState(pos, newState, 3);

View file

@ -21,13 +21,13 @@ import com.minelittlepony.util.shape.Sphere;
import net.fabricmc.fabric.api.particles.ParticleTypeRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@ -50,7 +50,7 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseab
@Nullable
private BlockPos destinationPos = null;
private EnumFacing.Axis axis = EnumFacing.Axis.Y;
private Direction.Axis axis = Direction.Axis.Y;
@Nullable
private UUID casterId;
@ -105,9 +105,9 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseab
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, BlockPos pos, Direction side, float hitX, float hitY, float hitZ) {
position = pos.offset(side);
axis = EnumFacing.getDirectionFromEntityLiving(position, player).getAxis();
axis = Direction.getDirectionFromEntityLiving(position, player).getAxis();
IPlayer prop = SpeciesList.instance().getPlayer(player);
@ -130,7 +130,7 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseab
}
@Override
public SpellCastResult onUse(ItemStack stack, Affinity affinity, EntityPlayer player, World world, @Nullable Entity hitEntity) {
public SpellCastResult onUse(ItemStack stack, Affinity affinity, PlayerEntity player, World world, @Nullable Entity hitEntity) {
return SpellCastResult.NONE;
}
@ -176,7 +176,7 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseab
}
public Box getTeleportBounds() {
if (axis == EnumFacing.Axis.Y) {
if (axis == Direction.Axis.Y) {
return TELEPORT_BOUNDS_VERT;
}
@ -188,19 +188,19 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseab
}
protected void teleportEntity(ICaster<?> source, SpellPortal dest, Entity i) {
EnumFacing.Axis xi = i.getHorizontalFacing().getAxis();
Direction.Axis xi = i.getHorizontalFacing().getAxis();
if (axis != EnumFacing.Axis.Y && xi != axis) {
if (axis != Direction.Axis.Y && xi != axis) {
return;
}
EnumFacing offset = i.getHorizontalFacing();
Direction offset = i.getHorizontalFacing();
double destX = dest.position.getX() + (i.posX - source.getOrigin().getX());
double destY = dest.position.getY() + (i.posY - source.getOrigin().getY());
double destZ = dest.position.getZ() + (i.posZ - source.getOrigin().getZ());
if (axis != EnumFacing.Axis.Y) {
if (axis != Direction.Axis.Y) {
destX += offset.getXOffset();
destY++;
destZ += offset.getZOffset();
@ -325,13 +325,13 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseab
}
if (compound.hasKey("axis")) {
axis = EnumFacing.Axis.byName(compound.getString("axis").toLowerCase(Locale.ROOT));
axis = Direction.Axis.byName(compound.getString("axis").toLowerCase(Locale.ROOT));
if (axis == null) {
axis = EnumFacing.Axis.Y;
axis = Direction.Axis.Y;
}
} else {
axis = EnumFacing.Axis.Y;
axis = Direction.Axis.Y;
}
}
}

View file

@ -17,7 +17,7 @@ import com.minelittlepony.util.shape.Sphere;
import net.fabricmc.fabric.api.particles.ParticleTypeRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.math.Vec3d;
@ -128,8 +128,8 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell implements IAttac
} else if (target instanceof LivingEntity) {
double force = Math.max(0.1, radius / 4);
if (source.getAffinity() != Affinity.BAD && target instanceof EntityPlayer) {
force *= calculateAdjustedForce(SpeciesList.instance().getPlayer((EntityPlayer)target));
if (source.getAffinity() != Affinity.BAD && target instanceof PlayerEntity) {
force *= calculateAdjustedForce(SpeciesList.instance().getPlayer((PlayerEntity)target));
} else {
force *= 0.75;
}

View file

@ -12,7 +12,7 @@ import com.minelittlepony.util.MagicalDamageSource;
import com.minelittlepony.util.shape.Sphere;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
@ -56,8 +56,8 @@ public class SpellSiphon extends AbstractSpell.RangedAreaSpell {
if (!e.equals(owner)) {
float dealt = Math.min(e.getHealth(), attackAmount);
if (e instanceof EntityPlayer) {
IPlayer player = SpeciesList.instance().getPlayer((EntityPlayer)e);
if (e instanceof PlayerEntity) {
IPlayer player = SpeciesList.instance().getPlayer((PlayerEntity)e);
Race race = player.getSpecies();

View file

@ -17,7 +17,7 @@ import com.minelittlepony.unicopia.UClient;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@ -32,7 +32,7 @@ public class MsgPlayerCapabilities implements IMessage, IMessageHandler<MsgPlaye
@Expose
byte[] compoundTag;
public MsgPlayerCapabilities(Race race, EntityPlayer player) {
public MsgPlayerCapabilities(Race race, PlayerEntity player) {
newRace = race;
senderId = player.getUniqueID();
compoundTag = new byte[0];
@ -54,7 +54,7 @@ public class MsgPlayerCapabilities implements IMessage, IMessageHandler<MsgPlaye
@Override
public void onPayload(MsgPlayerCapabilities message, IChannel channel) {
EntityPlayer self = UClient.instance().getPlayerByUUID(senderId);
PlayerEntity self = UClient.instance().getPlayerByUUID(senderId);
if (self == null) {
Unicopia.log.warn("[Unicopia] [CLIENT] [MsgPlayerCapabilities] Player with id %s was not found!\n", senderId.toString());

View file

@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.SpeciesList;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.player.IPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerEntity;
@IMessage.Id(0)
public class MsgRequestCapabilities implements IMessage, IMessageHandler<MsgRequestCapabilities> {
@ -21,7 +21,7 @@ public class MsgRequestCapabilities implements IMessage, IMessageHandler<MsgRequ
@Expose
public Race race;
public MsgRequestCapabilities(EntityPlayer player, Race preferredRace) {
public MsgRequestCapabilities(PlayerEntity player, Race preferredRace) {
senderId = player.getGameProfile().getId();
race = preferredRace;
}

View file

@ -0,0 +1,94 @@
package com.minelittlepony.unicopia.projectile;
import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.item.AdvancedProjectileEntity;
import com.minelittlepony.unicopia.magic.items.IDispensable;
import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundCategory;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPointer;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Position;
import net.minecraft.world.World;
public interface ITossableItem extends ITossable<ItemStack>, IDispensable {
default boolean canBeThrown(ItemStack stack) {
return true;
}
@Override
default TypedActionResult<ItemStack> dispenseStack(BlockPointer source, ItemStack stack) {
if (canBeThrown(stack)) {
stack = toss(source.getWorld(),
DispenserBlock.getOutputLocation(source),
source.getBlockState().get(DispenserBlock.FACING),
stack);
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
}
return new TypedActionResult<>(ActionResult.PASS, stack);
}
@Nullable
default IAdvancedProjectile createProjectile(World world, PlayerEntity player) {
return new AdvancedProjectileEntity(null, world, player);
}
@Nullable
default IAdvancedProjectile createProjectile(World world, Position pos) {
return new AdvancedProjectileEntity(null, world, pos.getX(), pos.getY(), pos.getZ());
}
default void toss(World world, ItemStack itemstack, PlayerEntity player) {
world.playSound(null, player.x, player.y, player.z, getThrowSound(itemstack), SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
if (!world.isClient) {
IAdvancedProjectile projectile = createProjectile(world, player);
if (projectile == null) {
return;
}
projectile.setItem(itemstack);
projectile.setThrowDamage(getThrowDamage(itemstack));
projectile.launch(player, player.pitch, player.yaw, 0, 1.5F, 1);
world.spawnEntity((Entity)projectile);
}
if (!player.abilities.creativeMode) {
itemstack.decrement(1);
}
player.incrementStat(Stats.USED.getOrCreateStat(itemstack.getItem()));
}
default ItemStack toss(World world, Position pos, Direction facing, ItemStack stack) {
IAdvancedProjectile projectile = createProjectile(world, pos);
if (projectile == null) {
return stack;
}
projectile.setItem(stack);
projectile.setThrowDamage(getThrowDamage(stack));
projectile.launch(facing.getOffsetX(), facing.getOffsetY() + 0.1F, facing.getOffsetZ(), 1.1F, 6);
world.spawnEntity((Entity)projectile);
stack.decrement(1);
return stack;
}
}

View file

@ -14,7 +14,7 @@ public class Hooks {
}
ActionResult result = UWorld.instance().getBlocks().onBlockInteract(
event.getWorld(), event.getWorld().getBlockState(event.getPos()), event.getPos(), event.getEntityPlayer(), event.getItemStack(), event.getFace(), event.getHand());
event.getWorld(), event.getWorld().getBlockState(event.getPos()), event.getPos(), event.getPlayerEntity(), event.getItemStack(), event.getFace(), event.getHand());
if (result != ActionResult.PASS) {
event.setCanceled(true);
@ -27,7 +27,7 @@ public class Hooks {
}
public static void onBlockTilled(UseHoeEvent event) {
if (UWorld.instance().getBlocks().onBlockTilled(event.getWorld(), event.getPos(), event.getEntityPlayer(), event.getCurrent())) {
if (UWorld.instance().getBlocks().onBlockTilled(event.getWorld(), event.getPos(), event.getPlayerEntity(), event.getCurrent())) {
event.setResult(Result.ALLOW);
}
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.world.structure;
import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.MutableBlockPos;
import net.minecraft.world.World;
@ -33,9 +33,9 @@ public abstract class AbstractFeature extends StructureComponent {
height = sizeY;
depth = sizeZ;
setCoordBaseMode(EnumFacing.Plane.HORIZONTAL.random(rand));
setCoordBaseMode(Direction.Plane.HORIZONTAL.random(rand));
if (getCoordBaseMode().getAxis() == EnumFacing.Axis.Z) {
if (getCoordBaseMode().getAxis() == Direction.Axis.Z) {
boundingBox = new StructureBoundingBox(x, y, z, x + sizeX - 1, y + sizeY - 1, z + sizeZ - 1);
} else {
boundingBox = new StructureBoundingBox(x, y, z, x + sizeZ - 1, y + sizeY - 1, z + sizeX - 1);