Lambdafy everything as they now work

This commit is contained in:
Vincent Lee committed 2016-07-24 10:36:58 -05:00
1 parent 3b5c500bc9
commit 881e271a0b
14 files changed
+64 -145

No files matched your search

@@ -41,25 +41,17 @@ public final class ColorHandler {
// 16 colors
blocks.registerBlockColorHandler(
new IBlockColor() {
@Override
public int colorMultiplier(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
return state.getValue(BotaniaStateProps.COLOR).getMapColor().colorValue;
}
},
(state, world, pos, tintIndex) -> state.getValue(BotaniaStateProps.COLOR).getMapColor().colorValue,
ModBlocks.specialFlower, ModBlocks.manaBeacon, ModBlocks.petalBlock, ModBlocks.unstableBlock);
// Pool
blocks.registerBlockColorHandler(
new IBlockColor() {
@Override
public int colorMultiplier(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
if (state.getValue(BotaniaStateProps.POOL_VARIANT) == PoolVariant.FABULOUS) {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.HSBtoRGB(time * 0.005F, 0.6F, 1F);
} else {
return state.getValue(BotaniaStateProps.COLOR).getMapColor().colorValue;
}
(state, world, pos, tintIndex) -> {
if (state.getValue(BotaniaStateProps.POOL_VARIANT) == PoolVariant.FABULOUS) {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.HSBtoRGB(time * 0.005F, 0.6F, 1F);
} else {
return state.getValue(BotaniaStateProps.COLOR).getMapColor().colorValue;
}
},
ModBlocks.pool
@@ -67,47 +59,40 @@ public final class ColorHandler {
// Spreader
blocks.registerBlockColorHandler(
new IBlockColor() {
@Override
public int colorMultiplier(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
if(state.getValue(BotaniaStateProps.SPREADER_VARIANT) != SpreaderVariant.GAIA)
return 0xFFFFFF;
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.HSBtoRGB((time * 5) % 360 / 360F, 0.4F, 0.9F);
}
(state, world, pos, tintIndex) -> {
if(state.getValue(BotaniaStateProps.SPREADER_VARIANT) != SpreaderVariant.GAIA)
return 0xFFFFFF;
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.HSBtoRGB((time * 5) % 360 / 360F, 0.4F, 0.9F);
},
ModBlocks.spreader
);
// Platforms
blocks.registerBlockColorHandler(
new IBlockColor() {
@Override
public int colorMultiplier(@Nonnull IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
if (world != null && pos != null) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileCamo) {
TileCamo camo = (TileCamo) tile;
IBlockState camoState = camo.camoState;
if(camoState != null)
return camoState.getBlock() instanceof BlockCamo ? 0xFFFFFF : Minecraft.getMinecraft().getBlockColors().colorMultiplier(camoState, world, pos, tintIndex);
}
(state, world, pos, tintIndex) -> {
if (world != null && pos != null) {
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileCamo) {
TileCamo camo = (TileCamo) tile;
IBlockState camoState = camo.camoState;
if(camoState != null)
return camoState.getBlock() instanceof BlockCamo
? 0xFFFFFF
: Minecraft.getMinecraft().getBlockColors().colorMultiplier(camoState, world, pos, tintIndex);
}
return 0xFFFFFF;
}
return 0xFFFFFF;
}, ModBlocks.platform);
ItemColors items = Minecraft.getMinecraft().getItemColors();
items.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(@Nonnull ItemStack stack, int tintIndex) {
Item item = stack.getItem();
if (item instanceof IColorable) {
return ((IColorable) item).getColorFromItemStack(stack, tintIndex);
} else {
return 0xFFFFFF;
}
items.registerItemColorHandler((stack, tintIndex) -> {
Item item = stack.getItem();
if (item instanceof IColorable) {
return ((IColorable) item).getColorFromItemStack(stack, tintIndex);
} else {
return 0xFFFFFF;
}
}, ModItems.manaResource, ModItems.twigWand, ModItems.dye, ModItems.petal, ModItems.manaGun, ModItems.manaMirror, ModItems.manaTablet, ModItems.signalFlare,
ModItems.spellCloth, ModItems.brewFlask, ModItems.brewVial, ModItems.incenseStick, ModItems.bloodPendant, ModItems.enderDagger,
@@ -53,12 +53,8 @@ public class ItemGrassHorn extends ItemMod {
super(LibItemNames.GRASS_HORN);
setMaxStackSize(1);
setHasSubtypes(true);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "vuvuzela"), new IItemPropertyGetter() {
@Override
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return stack.getDisplayName().toLowerCase(Locale.ROOT).contains("vuvuzela") ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "vuvuzela"),
(stack, worldIn, entityIn) -> stack.getDisplayName().toLowerCase(Locale.ROOT).contains("vuvuzela") ? 1 : 0);
}
@Override
@@ -38,12 +38,8 @@ public class ItemManaCookie extends ItemFood {
setCreativeTab(BotaniaCreativeTab.INSTANCE);
GameRegistry.register(this, new ResourceLocation(LibMisc.MOD_ID, LibItemNames.MANA_COOKIE));
setUnlocalizedName(LibItemNames.MANA_COOKIE);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "totalbiscuit"), new IItemPropertyGetter() {
@Override
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return stack.getDisplayName().toLowerCase(Locale.ROOT).contains("totalbiscuit") ? 1F : 0F;
}
});
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "totalbiscuit"),
(stack, worldIn, entityIn) -> stack.getDisplayName().toLowerCase(Locale.ROOT).contains("totalbiscuit") ? 1F : 0F);
}
@Override
@@ -76,18 +76,8 @@ public class ItemManaGun extends ItemMod implements IManaUsingItem, IColorable {
RecipeSorter.register("botania:manaGunRemoveLens", ManaGunRemoveLensRecipe.class, Category.SHAPELESS, "");
RecipeSorter.register("botania:manaGunClip", ManaGunClipRecipe.class, Category.SHAPELESS, "");
addPropertyOverride(new ResourceLocation("botania", "clip"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack itemStack, World world, EntityLivingBase entityLivingBase) {
return hasClip(itemStack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "desu"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack itemStack, World world, EntityLivingBase entityLivingBase) {
return isSugoiKawaiiDesuNe(itemStack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "clip"), (itemStack, world, entityLivingBase) -> hasClip(itemStack) ? 1 : 0);
addPropertyOverride(new ResourceLocation("botania", "desu"), (itemStack, world, entityLivingBase) -> isSugoiKawaiiDesuNe(itemStack) ? 1 : 0);
}
@Nonnull
@@ -46,12 +46,7 @@ public class ItemSpawnerMover extends ItemMod {
public ItemSpawnerMover() {
super(LibItemNames.SPAWNER_MOVER);
setMaxStackSize(1);
addPropertyOverride(new ResourceLocation("botania", "full"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityIn) {
return hasData(stack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "full"), (stack, worldIn, entityIn) -> hasData(stack) ? 1 : 0);
}
public static NBTTagCompound getSpawnerTag(ItemStack stack) {
@@ -69,12 +69,7 @@ public class ItemTwigWand extends Item16Colors implements ICoordBoundItem {
public ItemTwigWand() {
super(LibItemNames.TWIG_WAND);
setMaxStackSize(1);
addPropertyOverride(new ResourceLocation("botania", "bindmode"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityIn) {
return getBindMode(stack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "bindmode"), (stack, worldIn, entityIn) -> getBindMode(stack) ? 1 : 0);
}
@Nonnull
@@ -31,13 +31,10 @@ public class ItemBlockPool extends ItemBlockWithMetaNameAndColor {
public ItemBlockPool(Block par2Block) {
super(par2Block);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "full"), new IItemPropertyGetter() {
@Override
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
boolean renderFull = stack.getItemDamage() == PoolVariant.CREATIVE.ordinal() || (stack.hasTagCompound() && stack.getTagCompound().getBoolean("RenderFull"));
return renderFull ? 1F : 0F;
}
});
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "full"), (stack, worldIn, entityIn) -> {
boolean renderFull = stack.getItemDamage() == PoolVariant.CREATIVE.ordinal() || (stack.hasTagCompound() && stack.getTagCompound().getBoolean("RenderFull"));
return renderFull ? 1F : 0F;
});
}
@SideOnly(Side.CLIENT)
@@ -40,12 +40,7 @@ public class ItemManaweaveArmor extends ItemManasteelArmor implements ICraftAchi
public ItemManaweaveArmor(EntityEquipmentSlot type, String name) {
super(type, name, BotaniaAPI.manaweaveArmorMaterial);
addPropertyOverride(new ResourceLocation("botania", "holiday"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityIn) {
return ClientProxy.jingleTheBells ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "holiday"), (stack, worldIn, entityIn) -> ClientProxy.jingleTheBells ? 1 : 0);
}
@Override
@@ -56,12 +56,7 @@ public class ItemMagnetRing extends ItemBauble {
public ItemMagnetRing(String name, int range) {
super(name);
this.range = range;
addPropertyOverride(new ResourceLocation("botania", "on"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityIn) {
return ItemMagnetRing.getCooldown(stack) <= 0 ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "on"), (stack, worldIn, entityIn) -> ItemMagnetRing.getCooldown(stack) <= 0 ? 1 : 0);
}
@SubscribeEvent
@@ -62,20 +62,17 @@ public class ItemLivingwoodBow extends ItemBow implements IManaUsingItem {
GameRegistry.register(this, new ResourceLocation(LibMisc.MOD_ID, name));
setUnlocalizedName(name);
setMaxDamage(500);
addPropertyOverride(new ResourceLocation("minecraft:pull"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityIn) {
if (entityIn == null)
{
return 0.0F;
}
else
{
ItemStack itemstack = entityIn.getActiveItemStack();
return itemstack != null && itemstack.getItem() instanceof ItemLivingwoodBow ? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) * chargeVelocityMultiplier() / 20.0F : 0.0F;
}
}
});
addPropertyOverride(new ResourceLocation("minecraft:pull"), (stack, worldIn, entityIn) -> {
if (entityIn == null)
{
return 0.0F;
}
else
{
ItemStack itemstack = entityIn.getActiveItemStack();
return itemstack != null && itemstack.getItem() instanceof ItemLivingwoodBow ? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) * chargeVelocityMultiplier() / 20.0F : 0.0F;
}
});
}
@Nonnull
@@ -46,12 +46,8 @@ public class ItemManasteelSword extends ItemSword implements IManaUsingItem {
setCreativeTab(BotaniaCreativeTab.INSTANCE);
GameRegistry.register(this, new ResourceLocation(LibMisc.MOD_ID, name));
setUnlocalizedName(name);
addPropertyOverride(new ResourceLocation("botania", "elucidator"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World worldIn, EntityLivingBase entityIn) {
return "the elucidator".equals(stack.getDisplayName().toLowerCase().trim()) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "elucidator"),
(stack, worldIn, entityIn) -> "the elucidator".equals(stack.getDisplayName().toLowerCase().trim()) ? 1 : 0);
}
@Nonnull
@@ -81,14 +81,11 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_AXE);
MinecraftForge.EVENT_BUS.register(this);
this.attackSpeed = -3f;
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "terraaxe_on"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack stack, World world, EntityLivingBase entity) {
if(entity instanceof EntityPlayer && !shouldBreak(((EntityPlayer) entity)))
return 0;
return 1;
}
});
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "terraaxe_on"), (stack, world, entity) -> {
if(entity instanceof EntityPlayer && !shouldBreak(((EntityPlayer) entity)))
return 0;
return 1;
});
}
private boolean shouldBreak(EntityPlayer player) {
@@ -81,18 +81,8 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.TERRA_PICK);
GameRegistry.addRecipe(new TerraPickTippingRecipe());
RecipeSorter.register("botania:terraPickTipping", TerraPickTippingRecipe.class, Category.SHAPELESS, "");
addPropertyOverride(new ResourceLocation("botania", "tipped"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack itemStack, World world, EntityLivingBase entityLivingBase) {
return isTipped(itemStack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "enabled"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack itemStack, World world, EntityLivingBase entityLivingBase) {
return isEnabled(itemStack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "tipped"), (itemStack, world, entityLivingBase) -> isTipped(itemStack) ? 1 : 0);
addPropertyOverride(new ResourceLocation("botania", "enabled"), (itemStack, world, entityLivingBase) -> isEnabled(itemStack) ? 1 : 0);
}
@Override
@@ -56,12 +56,7 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
super(LibItemNames.TORNADO_ROD);
setMaxDamage(MAX_DAMAGE);
setMaxStackSize(1);
addPropertyOverride(new ResourceLocation("botania", "flying"), new IItemPropertyGetter() {
@Override
public float apply(@Nonnull ItemStack itemStack, World world, EntityLivingBase entityLivingBase) {
return isFlying(itemStack) ? 1 : 0;
}
});
addPropertyOverride(new ResourceLocation("botania", "flying"), (stack, world, living) -> isFlying(stack) ? 1 : 0);
}
@Override