chore: utils mostly ported, misc ported, deprecation's added, specials ported mostly

This commit is contained in:
Michael Hillcox 2021-03-01 16:25:30 +00:00
parent 6f34f82f4e
commit cb650b6689
44 changed files with 1001 additions and 1285 deletions

View file

@ -1,188 +1,189 @@
/*
* This file ("BlockGiantChest.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandlerModifiable;
import java.util.List;
public class BlockGiantChest extends BlockContainerBase {
public final int type;
public BlockGiantChest(String name, int type) {
super(Material.WOOD, name);
this.type = type;
this.setHarvestLevel("axe", 0);
this.setHardness(0.5F);
this.setResistance(15.0F);
this.setSoundType(SoundType.WOOD);
}
@Override
public TileEntity createNewTileEntity(IBlockReader worldIn) {
switch (this.type) {
case 1:
return new TileEntityGiantChestMedium();
case 2:
return new TileEntityGiantChestLarge();
default:
return new TileEntityGiantChest();
}
}
@Override
public boolean isFullCube(BlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(BlockState state) {
return false;
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!world.isRemote) {
TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
if (chest != null) {
chest.fillWithLoot(player);
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
return true;
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.EPIC;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase entity, ItemStack stack) {
if (stack.getTagCompound() != null) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityGiantChest) {
ListNBT list = stack.getTagCompound().getList("Items", 10);
IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv;
for (int i = 0; i < list.size(); i++) {
CompoundNBT compound = list.getCompound(i);
if (compound != null && compound.hasKey("id")) {
inv.setStackInSlot(i, new ItemStack(list.getCompound(i)));
}
}
}
}
super.onBlockPlacedBy(world, pos, state, entity, stack);
}
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
super.getDrops(drops, world, pos, state, fortune);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityGiantChest) {
ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv;
int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
if (place >= 0) {
ListNBT list = new ListNBT();
for (int i = 0; i < slots.getSlots(); i++) {
//Destroy the keeper
if (i != place) {
CompoundNBT compound = new CompoundNBT();
if (StackUtil.isValid(slots.getStackInSlot(i))) {
slots.getStackInSlot(i).writeToNBT(compound);
}
list.appendTag(compound);
}
}
if (list.size() > 0) {
ItemStack stackInQuestion = drops.get(0);
if (StackUtil.isValid(stackInQuestion)) {
if (stackInQuestion.getTagCompound() == null) {
stackInQuestion.setTagCompound(new CompoundNBT());
}
stackInQuestion.getTagCompound().setTag("Items", list);
}
}
}
}
}
@Override
public boolean shouldDropInventory(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
}
@Override
protected ItemBlockBase getItemBlock() {
return new TheItemBlock(this);
}
public static class TheItemBlock extends ItemBlockBase {
public TheItemBlock(Block block) {
super(block);
}
@Override
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
int type = this.block instanceof BlockGiantChest
? ((BlockGiantChest) this.block).type
: -1;
if (type == 2) {
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChestLarge.desc"));
} else if (type == 0) {
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChest.desc"));
}
}
@Override
public CompoundNBT getNBTShareTag(ItemStack stack) {
return null;
}
}
}
// TODO: [port][note] no longer used
///*
// * This file ("BlockGiantChest.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.blocks;
//
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
//import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
//import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
//import de.ellpeck.actuallyadditions.mod.items.InitItems;
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
//import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
//import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
//import net.minecraft.block.Block;
//import net.minecraft.block.SoundType;
//import net.minecraft.block.material.Material;
//import net.minecraft.client.util.ITooltipFlag;
//import net.minecraft.entity.EntityLivingBase;
//import net.minecraft.entity.player.PlayerEntity;
//import net.minecraft.item.EnumRarity;
//import net.minecraft.item.ItemStack;
//import net.minecraft.nbt.CompoundNBT;
//import net.minecraft.nbt.ListNBT;
//import net.minecraft.tileentity.TileEntity;
//import net.minecraft.util.Hand;
//import net.minecraft.util.NonNullList;
//import net.minecraft.util.math.BlockPos;
//import net.minecraft.util.text.TextFormatting;
//import net.minecraft.world.IBlockAccess;
//import net.minecraft.world.World;
//import net.minecraftforge.items.IItemHandlerModifiable;
//
//import java.util.List;
//
//public class BlockGiantChest extends BlockContainerBase {
//
// public final int type;
//
// public BlockGiantChest(String name, int type) {
// super(Material.WOOD, name);
// this.type = type;
//
// this.setHarvestLevel("axe", 0);
// this.setHardness(0.5F);
// this.setResistance(15.0F);
// this.setSoundType(SoundType.WOOD);
//
// }
//
// @Override
// public TileEntity createNewTileEntity(IBlockReader worldIn) {
// switch (this.type) {
// case 1:
// return new TileEntityGiantChestMedium();
// case 2:
// return new TileEntityGiantChestLarge();
// default:
// return new TileEntityGiantChest();
// }
// }
//
// @Override
// public boolean isFullCube(BlockState state) {
// return false;
// }
//
// @Override
// public boolean isOpaqueCube(BlockState state) {
// return false;
// }
//
// @Override
// public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
// if (!world.isRemote) {
// TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
// if (chest != null) {
// chest.fillWithLoot(player);
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
// }
// return true;
// }
// return true;
// }
//
// @Override
// public EnumRarity getRarity(ItemStack stack) {
// return EnumRarity.EPIC;
// }
//
// @Override
// public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase entity, ItemStack stack) {
// if (stack.getTagCompound() != null) {
// TileEntity tile = world.getTileEntity(pos);
// if (tile instanceof TileEntityGiantChest) {
// ListNBT list = stack.getTagCompound().getList("Items", 10);
// IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv;
//
// for (int i = 0; i < list.size(); i++) {
// CompoundNBT compound = list.getCompound(i);
// if (compound != null && compound.hasKey("id")) {
// inv.setStackInSlot(i, new ItemStack(list.getCompound(i)));
// }
// }
// }
// }
//
// super.onBlockPlacedBy(world, pos, state, entity, stack);
// }
//
// @Override
// public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
// super.getDrops(drops, world, pos, state, fortune);
// TileEntity tile = world.getTileEntity(pos);
// if (tile instanceof TileEntityGiantChest) {
// ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv;
// int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
// if (place >= 0) {
// ListNBT list = new ListNBT();
// for (int i = 0; i < slots.getSlots(); i++) {
// //Destroy the keeper
// if (i != place) {
// CompoundNBT compound = new CompoundNBT();
// if (StackUtil.isValid(slots.getStackInSlot(i))) {
// slots.getStackInSlot(i).writeToNBT(compound);
// }
// list.appendTag(compound);
// }
// }
//
// if (list.size() > 0) {
// ItemStack stackInQuestion = drops.get(0);
// if (StackUtil.isValid(stackInQuestion)) {
// if (stackInQuestion.getTagCompound() == null) {
// stackInQuestion.setTagCompound(new CompoundNBT());
// }
// stackInQuestion.getTagCompound().setTag("Items", list);
// }
// }
// }
// }
// }
//
// @Override
// public boolean shouldDropInventory(World world, BlockPos pos) {
// TileEntity tile = world.getTileEntity(pos);
// return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
// }
//
// @Override
// protected ItemBlockBase getItemBlock() {
// return new TheItemBlock(this);
// }
//
// public static class TheItemBlock extends ItemBlockBase {
//
// public TheItemBlock(Block block) {
// super(block);
// }
//
// @Override
// public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
// int type = this.block instanceof BlockGiantChest
// ? ((BlockGiantChest) this.block).type
// : -1;
// if (type == 2) {
// tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChestLarge.desc"));
// } else if (type == 0) {
// tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChest.desc"));
// }
// }
//
// @Override
// public CompoundNBT getNBTShareTag(ItemStack stack) {
// return null;
// }
// }
//}

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.material.Material;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
@ -20,30 +19,9 @@ import net.minecraftforge.fluids.Fluid;
public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity {
private final String name;
public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName) {
public BlockFluidFlowing(Fluid fluid, Material material) {
super(fluid, material);
this.name = unlocalizedName;
this.displacements.put(this, false);
this.register();
}
private void register() {
ItemUtil.registerBlock(this, this.getItemBlock(), this.getBaseName(), this.shouldAddCreative());
}
protected String getBaseName() {
return this.name;
}
protected ItemBlockBase getItemBlock() {
return new ItemBlockBase(this);
}
public boolean shouldAddCreative() {
return false;
}
@Override

View file

@ -10,33 +10,15 @@ import net.minecraftforge.registries.ForgeRegistries;
public class ActuallyContainers {
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MODID);
public static final RegistryObject<ContainerType<ContainerBag>> BAG_CONTAINER
= CONTAINERS.register("bag_container", () -> IForgeContainerType.create(ContainerBag::fromNetwork));
public static final RegistryObject<ContainerType<ContainerBioReactor>> BIO_REACTOR_CONTAINER
= CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork));
public static final RegistryObject<ContainerType<ContainerBreaker>> BREAKER_CONTAINER
= CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER
= CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCoalGenerator>> COAL_GENERATOR_CONTAINER
= CONTAINERS.register("coal_generator_container", () -> IForgeContainerType.create(ContainerCoalGenerator::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCoffeeMachine>> COFFEE_MACHINE_CONTAINER
= CONTAINERS.register("coffee_machine_container", () -> IForgeContainerType.create(ContainerCoffeeMachine::fromNetwork));
public static final RegistryObject<ContainerType<ContainerDirectionalBreaker>> DIRECTIONAL_BREAKER_CONTAINER
= CONTAINERS.register("directional_breaker_container", () -> IForgeContainerType.create(ContainerDirectionalBreaker::fromNetwork));
public static final RegistryObject<ContainerType<ContainerDropper>> DROPPER_CONTAINER
= CONTAINERS.register("dropper_container", () -> IForgeContainerType.create(ContainerDropper::fromNetwork));
public static final RegistryObject<ContainerType<ContainerEnervator>> ENERVATOR_CONTAINER
= CONTAINERS.register("enervator_container", () -> IForgeContainerType.create(ContainerEnervator::fromNetwork));
public static final RegistryObject<ContainerType<ContainerEnergizer>> ENERGIZER_CONTAINER
= CONTAINERS.register("energizer_container", () -> IForgeContainerType.create(ContainerEnergizer::fromNetwork));
public static final RegistryObject<ContainerType<ContainerBag>> BAG_CONTAINER = CONTAINERS.register("bag_container", () -> IForgeContainerType.create(ContainerBag::fromNetwork));
public static final RegistryObject<ContainerType<ContainerBioReactor>> BIO_REACTOR_CONTAINER = CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::fromNetwork));
public static final RegistryObject<ContainerType<ContainerBreaker>> BREAKER_CONTAINER = CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER = CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCoalGenerator>> COAL_GENERATOR_CONTAINER = CONTAINERS.register("coal_generator_container", () -> IForgeContainerType.create(ContainerCoalGenerator::fromNetwork));
public static final RegistryObject<ContainerType<ContainerCoffeeMachine>> COFFEE_MACHINE_CONTAINER = CONTAINERS.register("coffee_machine_container", () -> IForgeContainerType.create(ContainerCoffeeMachine::fromNetwork));
public static final RegistryObject<ContainerType<ContainerDirectionalBreaker>> DIRECTIONAL_BREAKER_CONTAINER = CONTAINERS.register("directional_breaker_container", () -> IForgeContainerType.create(ContainerDirectionalBreaker::fromNetwork));
public static final RegistryObject<ContainerType<ContainerDropper>> DROPPER_CONTAINER = CONTAINERS.register("dropper_container", () -> IForgeContainerType.create(ContainerDropper::fromNetwork));
public static final RegistryObject<ContainerType<ContainerEnervator>> ENERVATOR_CONTAINER = CONTAINERS.register("enervator_container", () -> IForgeContainerType.create(ContainerEnervator::fromNetwork));
public static final RegistryObject<ContainerType<ContainerEnergizer>> ENERGIZER_CONTAINER = CONTAINERS.register("energizer_container", () -> IForgeContainerType.create(ContainerEnergizer::fromNetwork));
}

View file

@ -33,6 +33,7 @@ public final class InitItems {
public static final RegistryObject<Item> itemMisc = ITEMS.register("item_misc", ItemBase::new);
public static final RegistryObject<Item> itemCanola = ITEMS.register("canola", ItemBase::new);
public static final RegistryObject<Item> itemCoffeeCup = ITEMS.register("coffee_cup", ItemBase::new);
public static final RegistryObject<Item> itemPaperCone = ITEMS.register("paper_cone", ItemBase::new);
// SHARDS
public static final RegistryObject<Item> RESTONIA_CRYSTAL_SHARD = ITEMS.register("item_restonia_crystal_shard", ItemBase::new);
@ -59,8 +60,7 @@ public final class InitItems {
// BLACK QUARTZ
public static final RegistryObject<Item> BLACK_QUARTZ = ITEMS.register("black_quartz", ItemBase::new);
public static final RegistryObject<Item> itemEngineerGogglesAdvanced = ITEMS.register("item_engineer_goggles_advanced", () -> new ItemEngineerGoggles(true));
public static final RegistryObject<Item> itemEngineerGoggles = ITEMS.register("item_engineer_goggles", () -> new ItemEngineerGoggles(false));
public static final RegistryObject<Item> itemLaserUpgradeRange = ITEMS.register("item_laser_upgrade_range", ItemBase::new);
@ -91,20 +91,20 @@ public final class InitItems {
public static final RegistryObject<Item> itemTeleStaff = ITEMS.register("item_tele_staff", ItemTeleStaff::new);
public static final RegistryObject<Item> itemWingsOfTheBats = ITEMS.register("item_wings_of_the_bats", ItemWingsOfTheBats::new);
public static final RegistryObject<Item> itemDrill = ITEMS.register("item_drill", ItemDrill::new);
public static final RegistryObject<Item> itemBattery = ITEMS.register("", new ItemBattery("item_battery", 200000, 1000));
public static final RegistryObject<Item> itemBatteryDouble = ITEMS.register("", new ItemBattery("item_battery_double", 350000, 5000));
public static final RegistryObject<Item> itemBatteryTriple = ITEMS.register("", new ItemBattery("item_battery_triple", 600000, 10000));
public static final RegistryObject<Item> itemBatteryQuadruple = ITEMS.register("", new ItemBattery("item_battery_quadruple", 1000000, 30000));
public static final RegistryObject<Item> itemBatteryQuintuple = ITEMS.register("", new ItemBattery("item_battery_quintuple", 2000000, 100000));
public static final RegistryObject<Item> itemDrillUpgradeSpeed = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED, "item_drill_upgrade_speed"));
public static final RegistryObject<Item> itemDrillUpgradeSpeedII = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II, "item_drill_upgrade_speed_ii"));
public static final RegistryObject<Item> itemDrillUpgradeSpeedIII = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_III, "item_drill_upgrade_speed_iii"));
public static final RegistryObject<Item> itemDrillUpgradeSilkTouch = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SILK_TOUCH, "item_drill_upgrade_silk_touch"));
public static final RegistryObject<Item> itemDrillUpgradeFortune = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE, "item_drill_upgrade_fortune"));
public static final RegistryObject<Item> itemDrillUpgradeFortuneII = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE_II, "item_drill_upgrade_fortune_ii"));
public static final RegistryObject<Item> itemDrillUpgradeThreeByThree = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.THREE_BY_THREE, "item_drill_upgrade_three_by_three"));
public static final RegistryObject<Item> itemDrillUpgradeFiveByFive = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE, "item_drill_upgrade_five_by_five"));
public static final RegistryObject<Item> itemDrillUpgradeBlockPlacing = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.PLACER, "item_drill_upgrade_block_placing"));
public static final RegistryObject<Item> itemBattery = ITEMS.register("item_battery", new ItemBattery(200000, 1000));
public static final RegistryObject<Item> itemBatteryDouble = ITEMS.register("item_battery_double", new ItemBattery(350000, 5000));
public static final RegistryObject<Item> itemBatteryTriple = ITEMS.register("item_battery_triple", new ItemBattery(600000, 10000));
public static final RegistryObject<Item> itemBatteryQuadruple = ITEMS.register("item_battery_quadruple", new ItemBattery(1000000, 30000));
public static final RegistryObject<Item> itemBatteryQuintuple = ITEMS.register("item_battery_quintuple", new ItemBattery(2000000, 100000));
public static final RegistryObject<Item> itemDrillUpgradeSpeed = ITEMS.register("item_drill_upgrade_speed", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED));
public static final RegistryObject<Item> itemDrillUpgradeSpeedII = ITEMS.register("item_drill_upgrade_speed_ii", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II));
public static final RegistryObject<Item> itemDrillUpgradeSpeedIII = ITEMS.register("item_drill_upgrade_speed_iii", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_III));
public static final RegistryObject<Item> itemDrillUpgradeSilkTouch = ITEMS.register("item_drill_upgrade_silk_touch", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SILK_TOUCH));
public static final RegistryObject<Item> itemDrillUpgradeFortune = ITEMS.register("item_drill_upgrade_fortune", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE));
public static final RegistryObject<Item> itemDrillUpgradeFortuneII = ITEMS.register("item_drill_upgrade_fortune_ii", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE_II));
public static final RegistryObject<Item> itemDrillUpgradeThreeByThree = ITEMS.register("item_drill_upgrade_three_by_three", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.THREE_BY_THREE));
public static final RegistryObject<Item> itemDrillUpgradeFiveByFive = ITEMS.register("item_drill_upgrade_five_by_five", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE));
public static final RegistryObject<Item> itemDrillUpgradeBlockPlacing = ITEMS.register("item_drill_upgrade_block_placing", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.PLACER));
public static final RegistryObject<Item> itemFertilizer = ITEMS.register("item_fertilizer", ItemFertilizer::new);
public static final RegistryObject<Item> itemCoffee = ITEMS.register("item_coffee", ItemCoffee::new);
public static final RegistryObject<Item> itemPhantomConnector = ITEMS.register("item_phantom_connector", ItemPhantomConnector::new);
@ -115,10 +115,10 @@ public final class InitItems {
public static final RegistryObject<Item> itemCrafterOnAStick = ITEMS.register("item_crafter_on_a_stick", ItemCrafterOnAStick::new);
public static final RegistryObject<Item> itemDust = ITEMS.register("item_dust", ItemDust::new);
public static final RegistryObject<Item> itemSolidifiedExperience = ITEMS.register("item_solidified_experience", ItemSolidifiedExperience::new);
public static final RegistryObject<Item> itemLeafBlower = ITEMS.register("", new ItemLeafBlower(false, "item_leaf_blower"));
public static final RegistryObject<Item> itemLeafBlowerAdvanced = ITEMS.register("", new ItemLeafBlower(true, "item_leaf_blower_advanced"));
public static final RegistryObject<Item> itemPotionRing = ITEMS.register("", new ItemPotionRing(false, "item_potion_ring"));
public static final RegistryObject<Item> itemPotionRingAdvanced = ITEMS.register("", new ItemPotionRing(true, "item_potion_ring_advanced"));
public static final RegistryObject<Item> itemLeafBlower = ITEMS.register("item_leaf_blower", new ItemLeafBlower(false));
public static final RegistryObject<Item> itemLeafBlowerAdvanced = ITEMS.register("item_leaf_blower_advanced", new ItemLeafBlower(true));
public static final RegistryObject<Item> itemPotionRing = ITEMS.register("item_potion_ring", new ItemPotionRing(false));
public static final RegistryObject<Item> itemPotionRingAdvanced = ITEMS.register("item_potion_ring_advanced", new ItemPotionRing(true));
public static final RegistryObject<Item> itemHairyBall = ITEMS.register("item_hairy_ball", ItemHairyBall::new);
public static final RegistryObject<Item> itemCoffeeBean = ITEMS.register("item_coffee_beans", ItemCoffeeBean::new);
public static final RegistryObject<Item> itemRiceSeed = ITEMS.register("", new ItemSeed("item_rice_seed", "seedRice", ActuallyBlocks.blockRice, itemFoods, TheFoods.RICE.ordinal()));

View file

@ -10,37 +10,8 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
public class ItemFoodBase extends ItemFood {
private final String name;
public ItemFoodBase(int heal, float saturation, boolean wolfFood, String name) {
public class ItemFoodBase extends ItemBase {
public ItemFoodBase(int heal, float saturation, boolean wolfFood) {
super(heal, saturation, wolfFood);
this.name = name;
this.register();
}
private void register() {
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
protected String getBaseName() {
return this.name;
}
public boolean shouldAddCreative() {
return true;
}
protected void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
}

View file

@ -10,12 +10,10 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeedFood;
import net.minecraft.item.ItemStack;
@ -39,14 +37,6 @@ public class ItemFoodSeed extends ItemSeedFood {
if (plant instanceof BlockPlant) {
((BlockPlant) plant).doStuff(this, returnItem, returnMeta);
}
this.register();
}
private void register() {
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
@Override
@ -54,23 +44,6 @@ public class ItemFoodSeed extends ItemSeedFood {
return this.maxUseDuration;
}
protected String getBaseName() {
return this.name;
}
public boolean shouldAddCreative() {
return true;
}
protected void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override
public BlockState getPlant(IBlockAccess world, BlockPos pos) {
return this.plant.getDefaultState();

View file

@ -11,29 +11,21 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.HoeItem;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IRarity;
public class ItemHoeAA extends HoeItem implements IDisableableItem {
private final String name;
private final IRarity rarity;
private final ItemStack repairItem;
private final boolean disabled;
public ItemHoeAA(IItemTier toolMat) {
super(toolMat);
this.repairItem = this.repairItem;
this.name = unlocalizedName;
this.rarity = this.rarity;
this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(this.name), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(this.name) + ". It will not be registered.");
if (!this.disabled) {
this.register();
@ -41,28 +33,8 @@ public class ItemHoeAA extends HoeItem implements IDisableableItem {
}
private void register() {
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
protected String getBaseName() {
return this.name;
}
public boolean shouldAddCreative() {
return true;
}
protected void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public IRarity getForgeRarity(ItemStack stack) {
return this.rarity;
}
@Override
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack) {
return ItemUtil.areItemsEqual(this.repairItem, stack, false);

View file

@ -10,58 +10,28 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
public class ItemSeed extends ItemSeeds {
public final Block plant;
public final String name;
public final String oredictName;
public ItemSeed(String name, String oredictName, Block plant, Item returnItem, int returnMeta) {
public ItemSeed(String oredictName, Block plant, Item returnItem, int returnMeta) {
super(plant, Blocks.FARMLAND);
this.name = name;
this.oredictName = oredictName;
this.plant = plant;
if (plant instanceof BlockPlant) {
((BlockPlant) plant).doStuff(this, returnItem, returnMeta);
}
this.register();
}
private void register() {
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
protected String getBaseName() {
return this.name;
}
public boolean shouldAddCreative() {
return true;
}
protected void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
@Override

View file

@ -11,7 +11,6 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
@ -19,21 +18,14 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraftforge.common.IRarity;
public class ItemSwordAA extends SwordItem implements IDisableableItem {
private final String name;
private final IRarity rarity;
private final ItemStack repairItem;
private final boolean disabled;
public ItemSwordAA(IItemTier toolMat) {
super(toolMat);
this.repairItem = this.repairItem;
this.name = unlocalizedName;
this.rarity = this.rarity;
this.disabled = ConfigurationHandler.config.getBoolean("Disable: " + StringUtil.badTranslate(this.name), "Tool Control", false, "This will disable the " + StringUtil.badTranslate(this.name) + ". It will not be registered.");
if (!this.disabled) {
@ -42,21 +34,6 @@ public class ItemSwordAA extends SwordItem implements IDisableableItem {
}
private void register() {
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
protected String getBaseName() {
return this.name;
}
public boolean shouldAddCreative() {
return true;
}
protected void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
protected Class<? extends ItemBlockBase> getItemBlock() {
@ -68,11 +45,6 @@ public class ItemSwordAA extends SwordItem implements IDisableableItem {
return ItemUtil.areItemsEqual(this.repairItem, stack, false);
}
@Override
public IRarity getForgeRarity(ItemStack stack) {
return this.rarity;
}
@Override
public boolean isDisabled() {
return this.disabled;

View file

@ -11,7 +11,6 @@
package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -27,7 +26,6 @@ import java.util.Set;
public class ItemToolAA extends ToolItem implements IDisableableItem {
private final String name;
private final IRarity rarity;
private final ItemStack repairItem;
private String repairOredict;
private final boolean disabled;
@ -50,26 +48,6 @@ public class ItemToolAA extends ToolItem implements IDisableableItem {
}
private void register() {
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
this.registerRendering();
}
protected String getBaseName() {
return this.name;
}
public boolean shouldAddCreative() {
return true;
}
protected void registerRendering() {
ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this), this.getRegistryName(), "inventory");
}
@Override
public IRarity getForgeRarity(ItemStack stack) {
return this.rarity;
}
@Override

View file

@ -16,15 +16,16 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.FakePlayerFactory;
import java.util.List;
@ -56,25 +57,25 @@ public class LensColor extends Lens {
if (tile.getEnergy() >= ENERGY_USE) {
BlockState state = tile.getWorldObject().getBlockState(hitBlock);
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
ItemStack returnStack = this.tryConvert(new ItemStack(block, 1, meta), hitState, hitBlock, tile);
if (returnStack != null && returnStack.getItem() instanceof ItemBlock) {
// int meta = block.getMetaFromState(state);
ItemStack returnStack = this.tryConvert(new ItemStack(block), hitState, hitBlock, tile);
if (returnStack != null && returnStack.getItem() instanceof BlockItem) {
Block toPlace = Block.getBlockFromItem(returnStack.getItem());
BlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), hitBlock, Direction.UP, 0, 0, 0, returnStack.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), Hand.MAIN_HAND);
BlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), hitBlock, Direction.UP, 0, 0, 0, returnStack.getMetadata(), FakePlayerFactory.getMinecraft((ServerWorld) tile.getWorldObject()), Hand.MAIN_HAND);
tile.getWorldObject().setBlockState(hitBlock, state2Place, 2);
tile.extractEnergy(ENERGY_USE);
}
}
List<EntityItem> items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
for (EntityItem item : items) {
if (!item.isDead && StackUtil.isValid(item.getItem()) && tile.getEnergy() >= ENERGY_USE) {
List<ItemEntity> items = tile.getWorldObject().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
for (ItemEntity item : items) {
if (item.isAlive() && StackUtil.isValid(item.getItem()) && tile.getEnergy() >= ENERGY_USE) {
ItemStack newStack = this.tryConvert(item.getItem(), hitState, hitBlock, tile);
if (StackUtil.isValid(newStack)) {
item.setDead();
item.remove();
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
tile.getWorldObject().spawnEntity(newItem);
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), newStack);
tile.getWorldObject().addEntity(newItem);
tile.extractEnergy(ENERGY_USE);
}

View file

@ -13,18 +13,19 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.misc.DamageSources;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.List;
public class LensDeath extends Lens {
@Override
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
ArrayList<EntityLivingBase> entities = (ArrayList<EntityLivingBase>) tile.getWorldObject().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
for (EntityLivingBase entity : entities) {
List<LivingEntity> entities = tile.getWorldObject().getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
for (LivingEntity entity : entities) {
int use = this.getUsePerEntity();
if (tile.getEnergy() >= use) {
tile.extractEnergy(use);
@ -33,10 +34,10 @@ public class LensDeath extends Lens {
}
}
return hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
}
protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) {
protected void onAttacked(LivingEntity entity, IAtomicReconstructor tile) {
entity.attackEntityFrom(DamageSources.DAMAGE_ATOMIC_RECONSTRUCTOR, 20F);
}

View file

@ -12,8 +12,10 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import net.minecraft.block.BlockState;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
public class LensDetonation extends Lens {
@ -23,7 +25,7 @@ public class LensDetonation extends Lens {
public boolean invoke(BlockState state, BlockPos hitBlock, IAtomicReconstructor tile) {
if (hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)) {
if (tile.getEnergy() >= ENERGY_USE) {
tile.getWorldObject().newExplosion(null, hitBlock.getX() + 0.5, hitBlock.getY() + 0.5, hitBlock.getZ() + 0.5, 10F, true, true);
tile.getWorldObject().createExplosion(null, hitBlock.getX() + 0.5, hitBlock.getY() + 0.5, hitBlock.getZ() + 0.5, 10F, true, Explosion.Mode.NONE); // TODO: [port][test] make sure this is the right explosion mode
tile.extractEnergy(ENERGY_USE);
}
return true;

View file

@ -14,14 +14,15 @@ import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Items;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemEnchantedBook;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@ -36,12 +37,12 @@ public class LensDisenchanting extends Lens {
@Override
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
if (tile.getEnergy() >= ENERGY_USE) {
List<EntityItem> items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
List<ItemEntity> items = tile.getWorldObject().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1));
if (items != null && !items.isEmpty()) {
EntityItem book = null;
EntityItem toDisenchant = null;
for (EntityItem item : items) {
if (item != null && !item.isDead) {
ItemEntity book = null;
ItemEntity toDisenchant = null;
for (ItemEntity item : items) {
if (item != null && item.isAlive()) {
ItemStack stack = item.getItem();
if (StackUtil.isValid(stack) && stack.getCount() == 1) {
Item stackItem = stack.getItem();
@ -70,7 +71,7 @@ public class LensDisenchanting extends Lens {
ItemStack bookStack = book.getItem();
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(disenchantStack);
if (enchants != null && !enchants.isEmpty()) {
if (!enchants.isEmpty()) {
Enchantment enchant = enchants.keySet().iterator().next();
int level = enchants.get(enchant);
@ -83,14 +84,14 @@ public class LensDisenchanting extends Lens {
}
ItemUtil.removeEnchantment(newDisenchantStack, enchant);
ItemEnchantedBook.addEnchantment(newBookStack, new EnchantmentData(enchant, level));
EnchantedBookItem.addEnchantment(newBookStack, new EnchantmentData(enchant, level));
EntityItem disenchanted = new EntityItem(toDisenchant.getEntityWorld(), toDisenchant.posX, toDisenchant.posY, toDisenchant.posZ, newDisenchantStack);
EntityItem newBook = new EntityItem(book.getEntityWorld(), book.posX, book.posY, book.posZ, newBookStack);
toDisenchant.setDead();
book.setDead();
tile.getWorldObject().spawnEntity(newBook);
tile.getWorldObject().spawnEntity(disenchanted);
ItemEntity disenchanted = new ItemEntity(toDisenchant.getEntityWorld(), toDisenchant.getPosX(), toDisenchant.getPosY(), toDisenchant.getPosZ(), newDisenchantStack);
ItemEntity newBook = new ItemEntity(book.getEntityWorld(), book.getPosX(), book.getPosY(), book.getPosZ(), newBookStack);
toDisenchant.remove();
book.remove();
tile.getWorldObject().addEntity(newBook);
tile.getWorldObject().addEntity(disenchanted);
tile.extractEnergy(ENERGY_USE);
@ -104,7 +105,7 @@ public class LensDisenchanting extends Lens {
@Override
public float[] getColor() {
return new float[]{234F / 255F, 173F / 255F, 255F / 255F};
return new float[]{234F / 255F, 173F / 255F, 1.0f};
}
@Override

View file

@ -16,15 +16,18 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.ArrayList;
import java.util.Random;
public class LensDisruption extends Lens {
@ -34,32 +37,28 @@ public class LensDisruption extends Lens {
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
if (ConfigIntValues.ELEVEN.getValue() == 11 && tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)) {
int range = 2;
ArrayList<EntityItem> items = (ArrayList<EntityItem>) tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX() - range, hitBlock.getY() - range, hitBlock.getZ() - range, hitBlock.getX() + range, hitBlock.getY() + range, hitBlock.getZ() + range));
for (EntityItem item : items) {
ArrayList<ItemEntity> items = (ArrayList<ItemEntity>) tile.getWorldObject().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(hitBlock.getX() - range, hitBlock.getY() - range, hitBlock.getZ() - range, hitBlock.getX() + range, hitBlock.getY() + range, hitBlock.getZ() + range));
for (ItemEntity item : items) {
ItemStack stack = item.getItem();
if (!item.isDead && StackUtil.isValid(stack)) {
if (!stack.hasTagCompound() || !stack.getTagCompound().getBoolean(ActuallyAdditions.MODID + "DisruptedAlready")) {
if (item.isAlive() && StackUtil.isValid(stack)) {
if (!stack.hasTag() || !stack.getOrCreateTag().getBoolean(ActuallyAdditions.MODID + "DisruptedAlready")) {
ItemStack newStack;
do {
if (tile.getWorldObject().rand.nextBoolean()) {
newStack = new ItemStack(Item.REGISTRY.getRandomObject(tile.getWorldObject().rand));
newStack = this.getRandomItemFromRegistry(tile.getWorldObject().rand);//new ItemStack(Item.REGISTRY.getRandomObject(tile.getWorldObject().rand));
} else {
newStack = new ItemStack(Block.REGISTRY.getRandomObject(tile.getWorldObject().rand));
newStack = this.getRandomBlockFromRegistry(tile.getWorldObject().rand);//new ItemStack(Block.REGISTRY.getRandomObject(tile.getWorldObject().rand));
}
} while (!StackUtil.isValid(newStack));
newStack.setCount(stack.getCount());
newStack.getOrCreateTag().putBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true);
if (!newStack.hasTagCompound()) {
newStack.setTagCompound(new CompoundNBT());
}
newStack.getTagCompound().putBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true);
item.remove();
item.setDead();
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
tile.getWorldObject().spawnEntity(newItem);
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), newStack);
tile.getWorldObject().addEntity(newItem);
tile.extractEnergy(ENERGY_USE);
}
@ -84,4 +83,12 @@ public class LensDisruption extends Lens {
public boolean canInvoke(IAtomicReconstructor tile, Direction sideToShootTo, int energyUsePerShot) {
return tile.getEnergy() - energyUsePerShot >= ENERGY_USE;
}
private ItemStack getRandomItemFromRegistry(Random random) {
return new ItemStack((Item) ForgeRegistries.ITEMS.getValues().toArray()[random.nextInt(ForgeRegistries.ITEMS.getValues().size())]);
}
private ItemStack getRandomBlockFromRegistry(Random random) {
return new ItemStack((Block) ForgeRegistries.BLOCKS.getValues().toArray()[random.nextInt(ForgeRegistries.BLOCKS.getValues().size())]);
}
}

View file

@ -11,17 +11,17 @@
package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.WorldServer;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.FakePlayerFactory;
public class LensKiller extends LensDeath {
@Override
protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) {
protected void onAttacked(LivingEntity entity, IAtomicReconstructor tile) {
if (!tile.getWorldObject().isRemote) {
entity.attackEntityFrom(DamageSource.causePlayerDamage(FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject())), 20);
entity.attackEntityFrom(DamageSource.causePlayerDamage(FakePlayerFactory.getMinecraft((ServerWorld) tile.getWorldObject())), 20);
}
}

View file

@ -21,18 +21,15 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockNetherrack;
import net.minecraft.block.BlockStone;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.NetherrackBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.oredict.OreDictionary;
import java.util.List;
@ -130,7 +127,7 @@ public class LensMining extends Lens {
Block hitBlock = hitState.getBlock();
if (hitBlock instanceof BlockStone) {
ores = ActuallyAdditionsAPI.STONE_ORES;
} else if (hitBlock instanceof BlockNetherrack) {
} else if (hitBlock instanceof NetherrackBlock) {
ores = ActuallyAdditionsAPI.NETHERRACK_ORES;
adaptedUse += 10000;
}

View file

@ -10,28 +10,24 @@
package de.ellpeck.actuallyadditions.mod.items.metalists;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.common.IRarity;
@Deprecated
public enum TheCrystals implements IStringSerializable {
REDSTONE("red", Util.CRYSTAL_RED_RARITY, 0xFF2F21, 158F / 255F, 43F / 255F, 39F / 255F),
LAPIS("blue", Util.CRYSTAL_BLUE_RARITY, 0x5171FF, 37F / 255F, 49F / 255F, 147F / 255F),
DIAMOND("light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY, 0x35F1FF, 99F / 255F, 135F / 255F, 210F / 255F),
COAL("black", Util.CRYSTAL_BLACK_RARITY, 0x434442, 0.2F, 0.2F, 0.2F),
EMERALD("green", Util.CRYSTAL_GREEN_RARITY, 0x44E033, 54F / 255F, 75F / 255F, 24F / 255F),
IRON("white", Util.CRYSTAL_WHITE_RARITY, 0xCEDDD4, 0.8F, 0.8F, 0.8F);
REDSTONE("red", 0xFF2F21, 158F / 255F, 43F / 255F, 39F / 255F),
LAPIS("blue", 0x5171FF, 37F / 255F, 49F / 255F, 147F / 255F),
DIAMOND("light_blue", 0x35F1FF, 99F / 255F, 135F / 255F, 210F / 255F),
COAL("black", 0x434442, 0.2F, 0.2F, 0.2F),
EMERALD("green", 0x44E033, 54F / 255F, 75F / 255F, 24F / 255F),
IRON("white", 0xCEDDD4, 0.8F, 0.8F, 0.8F);
public final String name;
public final IRarity rarity;
public final float[] conversionColorParticles;
public final int clusterColor;
TheCrystals(String name, IRarity rarity, int clusterColor, float... conversionColorParticles) {
TheCrystals(String name, int clusterColor, float... conversionColorParticles) {
this.name = name;
this.rarity = rarity;
this.conversionColorParticles = conversionColorParticles;
this.clusterColor = clusterColor;
}

View file

@ -11,27 +11,28 @@
package de.ellpeck.actuallyadditions.mod.items.metalists;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Rarity;
@Deprecated
public enum TheDusts {
IRON("iron", 7826534, EnumRarity.COMMON),
GOLD("gold", 14335744, EnumRarity.UNCOMMON),
DIAMOND("diamond", 292003, EnumRarity.RARE),
EMERALD("emerald", 4319527, EnumRarity.EPIC),
LAPIS("lapis", 1849791, EnumRarity.UNCOMMON),
QUARTZ("quartz", StringUtil.DECIMAL_COLOR_WHITE, EnumRarity.UNCOMMON),
COAL("coal", 0, EnumRarity.UNCOMMON),
QUARTZ_BLACK("quartz_black", 18, EnumRarity.RARE);
IRON("iron", 7826534, Rarity.COMMON),
GOLD("gold", 14335744, Rarity.UNCOMMON),
DIAMOND("diamond", 292003, Rarity.RARE),
EMERALD("emerald", 4319527, Rarity.EPIC),
LAPIS("lapis", 1849791, Rarity.UNCOMMON),
QUARTZ("quartz", StringUtil.DECIMAL_COLOR_WHITE, Rarity.UNCOMMON),
COAL("coal", 0, Rarity.UNCOMMON),
QUARTZ_BLACK("quartz_black", 18, Rarity.RARE);
public final String name;
public final int color;
public final EnumRarity rarity;
public final Rarity rarity;
TheDusts(String name, int color, EnumRarity rarity) {
TheDusts(String name, int color, Rarity rarity) {
this.name = name;
this.color = color;
this.rarity = rarity;
}
}
}

View file

@ -12,43 +12,44 @@ package de.ellpeck.actuallyadditions.mod.items.metalists;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.Rarity;
@Deprecated
public enum TheFoods {
CHEESE("cheese", 1, 0.05F, false, 3, EnumRarity.COMMON),
PUMPKIN_STEW("pumpkin_stew", 6, 0.3F, true, 30, EnumRarity.COMMON),
CARROT_JUICE("carrot_juice", 4, 0.2F, true, 20, EnumRarity.COMMON),
FISH_N_CHIPS("fish_n_chips", 14, 0.65F, false, 40, EnumRarity.UNCOMMON),
FRENCH_FRIES("french_fries", 10, 0.6F, false, 32, EnumRarity.COMMON),
FRENCH_FRY("french_fry", 2, 0.025F, false, 3, EnumRarity.COMMON),
SPAGHETTI("spaghetti", 7, 0.4F, false, 38, EnumRarity.COMMON),
NOODLE("noodle", 1, 0.01F, false, 3, EnumRarity.COMMON),
CHOCOLATE_CAKE("chocolate_cake", 16, 0.8F, false, 45, EnumRarity.UNCOMMON),
CHOCOLATE("chocolate", 3, 0.3F, false, 15, EnumRarity.COMMON),
TOAST("toast", 3, 0.08F, false, 25, EnumRarity.COMMON),
SUBMARINE_SANDWICH("submarine_sandwich", 9, 0.4F, false, 40, EnumRarity.UNCOMMON),
BIG_COOKIE("big_cookie", 4, 0.25F, false, 20, EnumRarity.UNCOMMON),
HAMBURGER("hamburger", 13, 0.65F, false, 40, EnumRarity.COMMON),
PIZZA("pizza", 16, 0.8F, false, 45, EnumRarity.UNCOMMON),
BAGUETTE("baguette", 6, 0.5F, false, 25, EnumRarity.COMMON),
RICE("rice", 2, 0.05F, false, 10, EnumRarity.UNCOMMON),
RICE_BREAD("rice_bread", 6, 0.5F, false, 25, EnumRarity.UNCOMMON),
DOUGHNUT("doughnut", 2, 0.1F, false, 10, EnumRarity.EPIC),
CHOCOLATE_TOAST("chocolate_toast", 5, 0.2F, false, 40, EnumRarity.RARE),
BACON("bacon", 4, 0.1F, false, 30, EnumRarity.COMMON);
CHEESE("cheese", 1, 0.05F, false, 3, Rarity.COMMON),
PUMPKIN_STEW("pumpkin_stew", 6, 0.3F, true, 30, Rarity.COMMON),
CARROT_JUICE("carrot_juice", 4, 0.2F, true, 20, Rarity.COMMON),
FISH_N_CHIPS("fish_n_chips", 14, 0.65F, false, 40, Rarity.UNCOMMON),
FRENCH_FRIES("french_fries", 10, 0.6F, false, 32, Rarity.COMMON),
FRENCH_FRY("french_fry", 2, 0.025F, false, 3, Rarity.COMMON),
SPAGHETTI("spaghetti", 7, 0.4F, false, 38, Rarity.COMMON),
NOODLE("noodle", 1, 0.01F, false, 3, Rarity.COMMON),
CHOCOLATE_CAKE("chocolate_cake", 16, 0.8F, false, 45, Rarity.UNCOMMON),
CHOCOLATE("chocolate", 3, 0.3F, false, 15, Rarity.COMMON),
TOAST("toast", 3, 0.08F, false, 25, Rarity.COMMON),
SUBMARINE_SANDWICH("submarine_sandwich", 9, 0.4F, false, 40, Rarity.UNCOMMON),
BIG_COOKIE("big_cookie", 4, 0.25F, false, 20, Rarity.UNCOMMON),
HAMBURGER("hamburger", 13, 0.65F, false, 40, Rarity.COMMON),
PIZZA("pizza", 16, 0.8F, false, 45, Rarity.UNCOMMON),
BAGUETTE("baguette", 6, 0.5F, false, 25, Rarity.COMMON),
RICE("rice", 2, 0.05F, false, 10, Rarity.UNCOMMON),
RICE_BREAD("rice_bread", 6, 0.5F, false, 25, Rarity.UNCOMMON),
DOUGHNUT("doughnut", 2, 0.1F, false, 10, Rarity.EPIC),
CHOCOLATE_TOAST("chocolate_toast", 5, 0.2F, false, 40, Rarity.RARE),
BACON("bacon", 4, 0.1F, false, 30, Rarity.COMMON);
public final String name;
public final int healAmount;
public final float saturation;
public final boolean getsDrunken;
public final int useDuration;
public final EnumRarity rarity;
public final Rarity rarity;
public ItemStack returnItem = StackUtil.getEmpty();
TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, EnumRarity rarity) {
TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, Rarity rarity) {
this.name = name;
this.getsDrunken = getsDrunken;
this.healAmount = healAmount;
@ -61,7 +62,7 @@ public enum TheFoods {
SPAGHETTI.returnItem = new ItemStack(Items.BOWL);
PUMPKIN_STEW.returnItem = new ItemStack(Items.BOWL);
CARROT_JUICE.returnItem = new ItemStack(Items.GLASS_BOTTLE);
FRENCH_FRIES.returnItem = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal());
FISH_N_CHIPS.returnItem = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal());
FRENCH_FRIES.returnItem = new ItemStack(InitItems.itemPaperCone.get());
FISH_N_CHIPS.returnItem = new ItemStack(InitItems.itemPaperCone.get());
}
}
}

View file

@ -10,27 +10,28 @@
package de.ellpeck.actuallyadditions.mod.items.metalists;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Rarity;
@Deprecated
public enum TheJams {
CU_BA_RA("cu_ba_ra", 6, 0.1F, EnumRarity.RARE, 5, 12, 12595273),
GRA_KI_BA("gra_ki_ba", 6, 0.1F, EnumRarity.RARE, 16, 13, 5492820),
PL_AP_LE("pl_ap_le", 6, 0.1F, EnumRarity.RARE, 15, 3, 13226009),
CH_AP_CI("ch_ap_ci", 6, 0.1F, EnumRarity.RARE, 10, 1, 13189222),
HO_ME_KI("ho_me_ki", 6, 0.1F, EnumRarity.RARE, 10, 14, 2031360),
PI_CO("pi_co", 6, 0.1F, EnumRarity.RARE, 9, 1, 16056203),
HO_ME_CO("ho_me_co", 6, 0.1F, EnumRarity.RARE, 10, 13, 10462208);
CU_BA_RA("cu_ba_ra", 6, 0.1F, Rarity.RARE, 5, 12, 12595273),
GRA_KI_BA("gra_ki_ba", 6, 0.1F, Rarity.RARE, 16, 13, 5492820),
PL_AP_LE("pl_ap_le", 6, 0.1F, Rarity.RARE, 15, 3, 13226009),
CH_AP_CI("ch_ap_ci", 6, 0.1F, Rarity.RARE, 10, 1, 13189222),
HO_ME_KI("ho_me_ki", 6, 0.1F, Rarity.RARE, 10, 14, 2031360),
PI_CO("pi_co", 6, 0.1F, Rarity.RARE, 9, 1, 16056203),
HO_ME_CO("ho_me_co", 6, 0.1F, Rarity.RARE, 10, 13, 10462208);
public final String name;
public final int healAmount;
public final float saturation;
public final EnumRarity rarity;
public final Rarity rarity;
public final int firstEffectToGet;
public final int secondEffectToGet;
public final int color;
TheJams(String name, int healAmount, float saturation, EnumRarity rarity, int firstEffectID, int secondEffectID, int color) {
TheJams(String name, int healAmount, float saturation, Rarity rarity, int firstEffectID, int secondEffectID, int color) {
this.name = name;
this.healAmount = healAmount;
this.saturation = saturation;
@ -39,4 +40,4 @@ public enum TheJams {
this.secondEffectToGet = secondEffectID;
this.color = color;
}
}
}

View file

@ -10,121 +10,131 @@
package de.ellpeck.actuallyadditions.mod.items.metalists;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.EnumRarity;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.Rarity;
import net.minecraft.potion.Potion;
@Deprecated
public enum ThePotionRings {
SPEED(
MobEffects.SPEED.getName(),
8171462,
MobEffects.SPEED,
0,
1,
10,
false,
EnumRarity.UNCOMMON,
new ItemStack(Items.SUGAR)),
MobEffects.SPEED.getName(),
8171462,
MobEffects.SPEED,
0,
1,
10,
false,
Rarity.UNCOMMON,
new ItemStack(Items.SUGAR)
),
//Slowness
HASTE(
MobEffects.HASTE.getName(),
14270531,
MobEffects.HASTE,
0,
1,
10,
false,
EnumRarity.EPIC,
new ItemStack(Items.REPEATER)),
MobEffects.HASTE.getName(),
14270531,
MobEffects.HASTE,
0,
1,
10,
false,
Rarity.EPIC,
new ItemStack(Items.REPEATER)
),
//Mining Fatigue
STRENGTH(
MobEffects.STRENGTH.getName(),
9643043,
MobEffects.STRENGTH,
0,
1,
10,
false,
EnumRarity.RARE,
new ItemStack(Items.BLAZE_POWDER)),
MobEffects.STRENGTH.getName(),
9643043,
MobEffects.STRENGTH,
0,
1,
10,
false,
Rarity.RARE,
new ItemStack(Items.BLAZE_POWDER)
),
//Health (Not Happening)
//Damage
JUMP_BOOST(
MobEffects.JUMP_BOOST.getName(),
7889559,
MobEffects.JUMP_BOOST,
0,
1,
10,
false,
EnumRarity.RARE,
new ItemStack(Blocks.PISTON)),
MobEffects.JUMP_BOOST.getName(),
7889559,
MobEffects.JUMP_BOOST,
0,
1,
10,
false,
Rarity.RARE,
new ItemStack(Blocks.PISTON)
),
//Nausea
REGEN(
MobEffects.REGENERATION.getName(),
13458603,
MobEffects.REGENERATION,
0,
1,
50,
true,
EnumRarity.RARE,
new ItemStack(Items.GHAST_TEAR)),
MobEffects.REGENERATION.getName(),
13458603,
MobEffects.REGENERATION,
0,
1,
50,
true,
Rarity.RARE,
new ItemStack(Items.GHAST_TEAR)
),
RESISTANCE(
MobEffects.RESISTANCE.getName(),
10044730,
MobEffects.RESISTANCE,
0,
1,
10,
false,
EnumRarity.EPIC,
new ItemStack(Items.SLIME_BALL)),
MobEffects.RESISTANCE.getName(),
10044730,
MobEffects.RESISTANCE,
0,
1,
10,
false,
Rarity.EPIC,
new ItemStack(Items.SLIME_BALL)
),
FIRE_RESISTANCE(
MobEffects.FIRE_RESISTANCE.getName(),
14981690,
MobEffects.FIRE_RESISTANCE,
0,
0,
10,
false,
EnumRarity.UNCOMMON,
new ItemStack(Items.MAGMA_CREAM)),
MobEffects.FIRE_RESISTANCE.getName(),
14981690,
MobEffects.FIRE_RESISTANCE,
0,
0,
10,
false,
Rarity.UNCOMMON,
new ItemStack(Items.MAGMA_CREAM)
),
WATER_BREATHING(
MobEffects.WATER_BREATHING.getName(),
3035801,
MobEffects.WATER_BREATHING,
0,
0,
10,
false,
EnumRarity.RARE,
new ItemStack(Items.FISH, 1, 3)),
MobEffects.WATER_BREATHING.getName(),
3035801,
MobEffects.WATER_BREATHING,
0,
0,
10,
false,
Rarity.RARE,
new ItemStack(Items.FISH, 1, 3)
),
INVISIBILITY(
MobEffects.INVISIBILITY.getName(),
8356754,
MobEffects.INVISIBILITY,
0,
0,
10,
false,
EnumRarity.EPIC,
new ItemStack(Items.FERMENTED_SPIDER_EYE)),
MobEffects.INVISIBILITY.getName(),
8356754,
MobEffects.INVISIBILITY,
0,
0,
10,
false,
Rarity.EPIC,
new ItemStack(Items.FERMENTED_SPIDER_EYE)
),
//Blindness
NIGHT_VISION(
MobEffects.NIGHT_VISION.getName(),
2039713,
MobEffects.NIGHT_VISION,
0,
0,
300,
false,
EnumRarity.RARE,
new ItemStack(Items.GOLDEN_CARROT));
MobEffects.NIGHT_VISION.getName(),
2039713,
MobEffects.NIGHT_VISION,
0,
0,
300,
false,
Rarity.RARE,
new ItemStack(Items.GOLDEN_CARROT)
);
//Hunger
//Weakness
//Poison
@ -134,7 +144,7 @@ public enum ThePotionRings {
public final String name;
public final int color;
public final EnumRarity rarity;
public final Rarity rarity;
public final int effectID;
public final int normalAmplifier;
public final int advancedAmplifier;
@ -142,7 +152,7 @@ public enum ThePotionRings {
public final boolean needsWaitBeforeActivating;
public final ItemStack craftingItem;
ThePotionRings(String name, int color, Potion effect, int normalAmplifier, int advancedAmplifier, int activeTime, boolean needsWaitBeforeActivating, EnumRarity rarity, ItemStack craftingItem) {
ThePotionRings(String name, int color, Potion effect, int normalAmplifier, int advancedAmplifier, int activeTime, boolean needsWaitBeforeActivating, Rarity rarity, ItemStack craftingItem) {
this.name = name;
this.color = color;
this.rarity = rarity;
@ -153,4 +163,4 @@ public enum ThePotionRings {
this.needsWaitBeforeActivating = needsWaitBeforeActivating;
this.craftingItem = craftingItem;
}
}
}

View file

@ -10,22 +10,23 @@
package de.ellpeck.actuallyadditions.mod.misc;
import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.item.ItemDye;
import net.minecraft.item.BoneMealItem;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
public class DispenserHandlerFertilize extends BehaviorDefaultDispenseItem {
// TODO: [port][note] might not be needed anymore
public class DispenserHandlerFertilize extends DefaultDispenseItemBehavior {
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
Direction facing = source.getBlockState().getValue(BlockDispenser.FACING);
Direction facing = source.getBlockState().get(BlockStateProperties.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
if (ItemDye.applyBonemeal(stack, source.getWorld(), pos)) {
if (BoneMealItem.applyBonemeal(stack, source.getWorld(), pos)) {
source.getWorld().playEvent(2005, pos, 0);
}

View file

@ -32,20 +32,20 @@ import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.WorldServer;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraftforge.common.util.FakePlayerFactory;
import java.util.ArrayList;
@ -57,10 +57,10 @@ public class MethodHandler implements IMethodHandler {
public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient) {
boolean worked = false;
if (ingredient != null) {
PotionEffect[] effects = ingredient.getEffects();
EffectInstance[] effects = ingredient.getEffects();
if (effects != null && effects.length > 0) {
for (PotionEffect effect : effects) {
PotionEffect effectHas = this.getSameEffectFromStack(stack, effect);
for (EffectInstance effect : effects) {
EffectInstance effectHas = this.getSameEffectFromStack(stack, effect);
if (effectHas != null) {
if (effectHas.getAmplifier() < ingredient.getMaxAmplifier() - 1) {
this.addEffectProperties(stack, effect, false, true);
@ -77,10 +77,10 @@ public class MethodHandler implements IMethodHandler {
}
@Override
public PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect) {
PotionEffect[] effectsStack = this.getEffectsFromStack(stack);
public EffectInstance getSameEffectFromStack(ItemStack stack, EffectInstance effect) {
EffectInstance[] effectsStack = this.getEffectsFromStack(stack);
if (effectsStack != null && effectsStack.length > 0) {
for (PotionEffect effectStack : effectsStack) {
for (EffectInstance effectStack : effectsStack) {
if (effect.getPotion() == effectStack.getPotion()) {
return effectStack;
}
@ -90,12 +90,12 @@ public class MethodHandler implements IMethodHandler {
}
@Override
public void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp) {
PotionEffect[] effects = this.getEffectsFromStack(stack);
stack.setTagCompound(new CompoundNBT());
public void addEffectProperties(ItemStack stack, EffectInstance effect, boolean addDur, boolean addAmp) {
EffectInstance[] effects = this.getEffectsFromStack(stack);
stack.setTag(new CompoundNBT());
for (int i = 0; i < effects.length; i++) {
if (effects[i].getPotion() == effect.getPotion()) {
effects[i] = new PotionEffect(effects[i].getPotion(), effects[i].getDuration() + (addDur
effects[i] = new EffectInstance(effects[i].getPotion(), effects[i].getDuration() + (addDur
? effect.getDuration()
: 0), effects[i].getAmplifier() + (addAmp
? effect.getAmplifier() > 0
@ -108,40 +108,35 @@ public class MethodHandler implements IMethodHandler {
}
@Override
public void addEffectToStack(ItemStack stack, PotionEffect effect) {
CompoundNBT tag = stack.getTagCompound();
if (tag == null) {
tag = new CompoundNBT();
}
public void addEffectToStack(ItemStack stack, EffectInstance effect) {
CompoundNBT tag = stack.getOrCreateTag();
int prevCounter = tag.getInteger("Counter");
int prevCounter = tag.putInt("Counter");
CompoundNBT compound = new CompoundNBT();
compound.putInt("ID", Potion.getIdFromPotion(effect.getPotion()));
compound.putInt("Duration", effect.getDuration());
compound.putInt("Amplifier", effect.getAmplifier());
int counter = prevCounter + 1;
tag.setTag(counter + "", compound);
tag.setInteger("Counter", counter);
tag.put(counter + "", compound);
tag.putInt("Counter", counter);
stack.setTagCompound(tag);
stack.setTag(tag);
}
@Override
public PotionEffect[] getEffectsFromStack(ItemStack stack) {
ArrayList<PotionEffect> effects = new ArrayList<>();
CompoundNBT tag = stack.getTagCompound();
if (tag != null) {
int counter = tag.getInteger("Counter");
while (counter > 0) {
CompoundNBT compound = (CompoundNBT) tag.getTag(counter + "");
PotionEffect effect = new PotionEffect(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
effects.add(effect);
counter--;
}
public EffectInstance[] getEffectsFromStack(ItemStack stack) {
ArrayList<EffectInstance> effects = new ArrayList<>();
CompoundNBT tag = stack.getOrCreateTag();
int counter = tag.getInt("Counter");
while (counter > 0) {
CompoundNBT compound = (CompoundNBT) tag.get(counter + "");
EffectInstance effect = new EffectInstance(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
effects.add(effect);
counter--;
}
return effects.size() > 0
? effects.toArray(new PotionEffect[effects.size()])
? effects.toArray(new EffectInstance[effects.size()])
: null;
}
@ -188,8 +183,8 @@ public class MethodHandler implements IMethodHandler {
BlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), Hand.MAIN_HAND);
tile.getWorldObject().setBlockState(pos, state2Place, 2);
} else {
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy());
tile.getWorldObject().spawnEntity(item);
ItemEntity item = new ItemEntity(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy());
tile.getWorldObject().addEntity(item);
tile.getWorldObject().setBlockState(pos, Blocks.AIR.getDefaultState());
}
@ -204,34 +199,34 @@ public class MethodHandler implements IMethodHandler {
//Converting the Items
AxisAlignedBB aabb = new AxisAlignedBB(tile.getPosition().getX(), tile.getPosition().getY(), tile.getPosition().getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1);
Vec3i dir = tile.getOrientation().getDirectionVec();
Vector3i dir = tile.getOrientation().getDirectionVec();
aabb = aabb.grow(0.02, 0.02, 0.02).expand(dir.getX(), dir.getY(), dir.getZ());
List<EntityItem> items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, aabb);
for (EntityItem item : items) {
List<ItemEntity> items = tile.getWorldObject().getEntitiesWithinAABB(ItemEntity.class, aabb);
for (ItemEntity item : items) {
ItemStack stack = item.getItem();
if (!item.isDead && StackUtil.isValid(stack) && !item.getEntityData().getBoolean("aa_cnv")) {
if (item.isAlive() && StackUtil.isValid(stack) && !item.getEntityData().getBoolean("aa_cnv")) {
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens());
if (recipe != null) {
int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount());
if (itemsPossible > 0) {
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
item.setDead();
item.remove();
if (stack.getCount() - itemsPossible > 0) {
ItemStack stackCopy = stack.copy();
stackCopy.shrink(itemsPossible);
EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy);
tile.getWorldObject().spawnEntity(inputLeft);
ItemEntity inputLeft = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), stackCopy);
tile.getWorldObject().addEntity(inputLeft);
}
ItemStack outputCopy = recipe.getOutput().copy();
outputCopy.setCount(itemsPossible);
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy);
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), outputCopy);
newItem.getEntityData().putBoolean("aa_cnv", true);
tile.getWorldObject().spawnEntity(newItem);
tile.getWorldObject().addEntity(newItem);
tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible);
break;

View file

@ -33,7 +33,7 @@ public class CactusFarmerBehavior implements IFarmerBehavior {
if (item instanceof BlockItem) {
Block block = Block.getBlockFromItem(item);
if (block == Blocks.CACTUS) {
if (block.canPlaceBlockAt(world, pos)) {
if (block.getDefaultState().isValidPosition(world, pos)) {
BlockState state = block.getDefaultState();
world.setBlockState(pos, state, 2);
world.playEvent(2001, pos, Block.getStateId(state));

View file

@ -14,24 +14,18 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.IGrowable;
import net.minecraft.block.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.init.Items;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundCategory;
import net.minecraft.item.Items;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.util.FakePlayerFactory;
import java.util.ArrayList;
@ -43,7 +37,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
if (toPlant != null) {
BlockPos farmland = pos.down();
Block farmlandBlock = world.getBlockState(farmland).getBlock();
if (farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass) {
if (Tags.Blocks.DIRT.contains(farmlandBlock) || farmlandBlock == Blocks.GRASS) {
world.setBlockState(pos, Blocks.AIR.getDefaultState());
useHoeAt(world, farmland);
world.playSound(null, farmland, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
@ -59,7 +53,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
}
private static boolean tryPlant(BlockState toPlant, World world, BlockPos pos) {
if (toPlant.getBlock().canPlaceBlockAt(world, pos)) {
if (toPlant.isValidPosition(world, pos)) {
world.setBlockState(pos, toPlant);
return true;
}
@ -84,15 +78,17 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
BlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block instanceof BlockCrops) {
if (((BlockCrops) block).isMaxAge(state)) {
return this.doFarmerStuff(state, world, pos, farmer);
}
} else if (BlockCrops.AGE.equals(block.getBlockState().getProperty("age"))) {
if (state.getValue(BlockCrops.AGE) >= 7 && !(block instanceof BlockStem)) {
if (block instanceof CropsBlock) {
if (((CropsBlock) block).isMaxAge(state)) {
return this.doFarmerStuff(state, world, pos, farmer);
}
}
// TODO: [port] come back and see what this is actually doing
// else if (CropsBlock.AGE.equals(block.getBlockState().getProperty("age"))) {
// if (state.get(BlockStateProperties.AGE_0_7) >= 7 && !(block instanceof StemBlock)) {
// return this.doFarmerStuff(state, world, pos, farmer);
// }
// }
}
return FarmerResult.FAIL;
}
@ -154,7 +150,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
Item item = stack.getItem();
if (item instanceof IPlantable) {
return (IPlantable) item;
} else if (item instanceof ItemBlock) {
} else if (item instanceof BlockItem) {
Block block = Block.getBlockFromItem(item);
if (block instanceof IPlantable) {
return (IPlantable) block;
@ -172,20 +168,20 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
return hoe;
}
public static EnumActionResult useHoeAt(World world, BlockPos pos) {
public static ActionResultType useHoeAt(World world, BlockPos pos) {
PlayerEntity player = FakePlayerFactory.getMinecraft((WorldServer) world);
PlayerEntity player = FakePlayerFactory.getMinecraft((ServerWorld) world);
ItemStack itemstack = getHoeStack();
if (!player.canPlayerEdit(pos.offset(Direction.UP), Direction.UP, itemstack)) {
return EnumActionResult.FAIL;
return ActionResultType.FAIL;
} else {
int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(itemstack, player, world, pos);
if (hook != 0) {
return hook > 0
? EnumActionResult.SUCCESS
: EnumActionResult.FAIL;
? ActionResultType.SUCCESS
: ActionResultType.FAIL;
}
BlockState iblockstate = world.getBlockState(pos);
@ -194,23 +190,23 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
if (world.isAirBlock(pos.up())) {
if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) {
world.setBlockState(pos, Blocks.FARMLAND.getDefaultState());
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
}
if (block == Blocks.DIRT) {
switch (iblockstate.getValue(BlockDirt.VARIANT)) {
switch (iblockstate.get(BlockDirt.VARIANT)) {
case DIRT:
world.setBlockState(pos, Blocks.FARMLAND.getDefaultState());
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
case COARSE_DIRT:
world.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
return EnumActionResult.SUCCESS;
return ActionResultType.SUCCESS;
default:
}
}
}
return EnumActionResult.PASS;
return ActionResultType.PASS;
}
}
}

View file

@ -15,10 +15,11 @@ import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -55,7 +56,7 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior {
if (farmer.getEnergy() >= use) {
BlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == Blocks.PUMPKIN || block == Blocks.MELON_BLOCK) {
if (block == Blocks.PUMPKIN || block == Blocks.MELON) {
NonNullList<ItemStack> drops = NonNullList.create();
block.getDrops(drops, world, pos, state, 0);
if (!drops.isEmpty()) {

View file

@ -14,10 +14,12 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockNetherWart;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.NetherWartBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
@ -47,8 +49,8 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior {
int use = 500;
if (farmer.getEnergy() >= use) {
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockNetherWart) {
if (state.getValue(BlockNetherWart.AGE) >= 3) {
if (state.getBlock() instanceof NetherWartBlock) {
if (state.get(BlockStateProperties.AGE_0_3) >= 3) {
NonNullList<ItemStack> drops = NonNullList.create();
state.getBlock().getDrops(drops, world, pos, state, 0);
if (!drops.isEmpty()) {

View file

@ -14,10 +14,11 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockReed;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SugarCaneBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -28,9 +29,9 @@ public class ReedFarmerBehavior implements IFarmerBehavior {
public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) {
int use = 250;
if (farmer.getEnergy() >= use) {
if (seed.getItem() == Items.REEDS) {
if (Blocks.REEDS.canPlaceBlockAt(world, pos)) {
world.setBlockState(pos, Blocks.REEDS.getDefaultState(), 2);
if (seed.getItem() == Items.SUGAR_CANE) {
if (Blocks.SUGAR_CANE.getDefaultState().isValidPosition(world, pos)) {
world.setBlockState(pos, Blocks.SUGAR_CANE.getDefaultState(), 2);
farmer.extractEnergy(use);
return FarmerResult.SUCCESS;
}
@ -45,14 +46,14 @@ public class ReedFarmerBehavior implements IFarmerBehavior {
int use = 250;
if (farmer.getEnergy() >= use) {
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockReed) {
if (state.getBlock() instanceof SugarCaneBlock) {
FarmerResult result = FarmerResult.STOP_PROCESSING;
for (int i = 2; i >= 1; --i) {
if (farmer.getEnergy() >= use) {
BlockPos up = pos.up(i);
BlockState upState = world.getBlockState(up);
if (upState.getBlock() instanceof BlockReed) {
if (upState.getBlock() instanceof SugarCaneBlock) {
NonNullList<ItemStack> drops = NonNullList.create();
upState.getBlock().getDrops(drops, world, pos, state, 0);

View file

@ -10,12 +10,19 @@
package de.ellpeck.actuallyadditions.mod.misc.special;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerModelPart;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Util;
import net.minecraft.util.math.vector.Vector3d;
public class RenderSpecial {
@ -25,54 +32,54 @@ public class RenderSpecial {
this.theThingToRender = stack;
}
public void render(PlayerEntity player, float partialTicks) {
if (player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()) {
public void render(MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight, PlayerEntity player, float partialTicks) {
if (player.isInvisible() || !player.isWearing(PlayerModelPart.CAPE) || player.isElytraFlying()) {
return;
}
GlStateManager.pushMatrix();
Vec3d currentPos = Minecraft.getInstance().player.getPositionEyes(partialTicks);
Vec3d playerPos = player.getPositionEyes(partialTicks);
GlStateManager.translate(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z);
GlStateManager.translate(0D, 2.575D - (player.isSneaking()
Vector3d currentPos = Minecraft.getInstance().player.getEyePosition(partialTicks);
Vector3d playerPos = player.getEyePosition(partialTicks);
GlStateManager.translated(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z);
GlStateManager.translated(0D, 2.575D - (player.isSneaking()
? 0.125D
: 0D), 0D);
this.render();
this.render(matrices, buffer, combinedLight);
GlStateManager.popMatrix();
}
public void render() {
public void render(MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight) {
if (StackUtil.isValid(this.theThingToRender)) {
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
boolean isBlock = this.theThingToRender.getItem() instanceof BlockItem;
GlStateManager.pushMatrix();
if (isBlock) {
GlStateManager.translate(0D, -0.1875D, 0D);
GlStateManager.translated(0D, -0.1875D, 0D);
}
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
GlStateManager.rotatef(180F, 1.0F, 0.0F, 1.0F);
float size = isBlock
? 0.5F
: 0.4F;
GlStateManager.scale(size, size, size);
GlStateManager.scalef(size, size, size);
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
//Peck edit: What do you mean by "nice" you jackass? >_>
double boop = Minecraft.getSystemTime() / 1000D;
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D);
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
double boop = Util.milliTime() / 1000D;
GlStateManager.translated(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D);
GlStateManager.rotatef((float) (boop * 40D % 360), 0, 1, 0);
GlStateManager.disableLighting();
GlStateManager.pushMatrix();
if (!isBlock) {
GlStateManager.translate(0D, 0.5D, 0D);
GlStateManager.translated(0D, 0.5D, 0D);
}
GlStateManager.rotate(180F, 1F, 0F, 0F);
AssetUtil.renderItemInWorld(this.theThingToRender, combinedLightIn, combinedOverlayIn, matrices, buffer);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
AssetUtil.renderItemInWorld(this.theThingToRender, combinedLight, OverlayTexture.NO_OVERLAY, matrices, buffer);
GlStateManager.popMatrix();
GlStateManager.enableLighting();

View file

@ -16,8 +16,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.HashMap;
import java.util.Locale;
@ -31,6 +32,7 @@ public class SpecialRenderInit {
new ThreadSpecialFetcher();
}
// TODO: [port][note] ensure that this still works with the special people stuff
public static void parse(Properties properties) {
for (String key : properties.stringPropertyNames()) {
String[] values = properties.getProperty(key).split("@");
@ -45,7 +47,7 @@ public class SpecialRenderInit {
}
ResourceLocation resLoc = new ResourceLocation(itemName);
ItemStack stack = findItem(resLoc, meta);
ItemStack stack = findItem(resLoc);
//TODO Remove this block once the transition to 1.11 is done and the special people stuff file has been converted to snake_case
if (!StackUtil.isValid(stack)) {
@ -58,7 +60,7 @@ public class SpecialRenderInit {
convertedItemName += c;
}
}
stack = findItem(new ResourceLocation(convertedItemName), meta);
stack = findItem(new ResourceLocation(convertedItemName));
}
if (StackUtil.isValid(stack)) {
@ -68,16 +70,16 @@ public class SpecialRenderInit {
}
}
private static ItemStack findItem(ResourceLocation resLoc, int meta) {
if (Item.REGISTRY.containsKey(resLoc)) {
Item item = Item.REGISTRY.getObject(resLoc);
private static ItemStack findItem(ResourceLocation resLoc) {
if (ForgeRegistries.ITEMS.containsKey(resLoc)) {
Item item = ForgeRegistries.ITEMS.getValue(resLoc);
if (item != null) {
return new ItemStack(item, 1, meta);
return new ItemStack(item);
}
} else if (Block.REGISTRY.containsKey(resLoc)) {
Block block = Block.REGISTRY.getObject(resLoc);
} else if (ForgeRegistries.BLOCKS.containsKey(resLoc)) {
Block block = ForgeRegistries.BLOCKS.getValue(resLoc);
if (block != null) {
return new ItemStack(block, 1, meta);
return new ItemStack(block);
}
}
return StackUtil.getEmpty();
@ -85,15 +87,13 @@ public class SpecialRenderInit {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerRender(RenderPlayerEvent.Pre event) {
if (event.getEntityPlayer() != null) {
String name = event.getEntityPlayer().getName();
if (name != null) {
String lower = name.toLowerCase(Locale.ROOT);
if (SPECIAL_LIST.containsKey(lower)) {
RenderSpecial render = SPECIAL_LIST.get(lower);
if (render != null) {
render.render(event.getEntityPlayer(), event.getPartialRenderTick());
}
if (event.getPlayer() != null) {
String name = event.getPlayer().getName().getString();
String lower = name.toLowerCase(Locale.ROOT);
if (SPECIAL_LIST.containsKey(lower)) {
RenderSpecial render = SPECIAL_LIST.get(lower);
if (render != null) {
render.render(event.getMatrixStack(), event.getBuffers(), event.getLight(), event.getPlayer(), event.getPartialRenderTick());
}
}
}

View file

@ -18,11 +18,12 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraft.item.Items;
// TODO: [port][change] migrate to TAGS
@Deprecated
public final class InitOreDict {
public static void init() {
@ -32,49 +33,49 @@ public final class InitOreDict {
addOre(Items.COAL, "coal");
//Ores for Pulverizers etc.
addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron");
addOre(InitItems.itemDust, TheDusts.GOLD.ordinal(), "dustGold");
addOre(InitItems.itemDust, TheDusts.DIAMOND.ordinal(), "dustDiamond");
addOre(InitItems.itemDust, TheDusts.EMERALD.ordinal(), "dustEmerald");
addOre(InitItems.itemDust, TheDusts.LAPIS.ordinal(), "dustLapis");
addOre(InitItems.itemDust, TheDusts.QUARTZ.ordinal(), "dustQuartz");
addOre(InitItems.itemDust, TheDusts.QUARTZ.ordinal(), "dustNetherQuartz");
addOre(InitItems.itemDust, TheDusts.COAL.ordinal(), "dustCoal");
addOre(InitItems.itemDust, TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
addOre(ActuallyBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
addOre(InitItems.itemMisc, TheMiscItems.QUARTZ.ordinal(), "gemQuartzBlack");
addOre(InitItems.itemDust.get(), TheDusts.IRON.ordinal(), "dustIron");
addOre(InitItems.itemDust.get(), TheDusts.GOLD.ordinal(), "dustGold");
addOre(InitItems.itemDust.get(), TheDusts.DIAMOND.ordinal(), "dustDiamond");
addOre(InitItems.itemDust.get(), TheDusts.EMERALD.ordinal(), "dustEmerald");
addOre(InitItems.itemDust.get(), TheDusts.LAPIS.ordinal(), "dustLapis");
addOre(InitItems.itemDust.get(), TheDusts.QUARTZ.ordinal(), "dustQuartz");
addOre(InitItems.itemDust.get(), TheDusts.QUARTZ.ordinal(), "dustNetherQuartz");
addOre(InitItems.itemDust.get(), TheDusts.COAL.ordinal(), "dustCoal");
addOre(InitItems.itemDust.get(), TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
addOre(InitItems.itemMisc.get(), TheMiscItems.QUARTZ.ordinal(), "gemQuartzBlack");
//For Thermal Expansion Machine that "grows crops"
addOre(InitItems.itemCanolaSeed, "seedCanola");
addOre(InitItems.itemMisc, TheMiscItems.CANOLA.ordinal(), "cropCanola");
addOre(InitItems.itemRiceSeed, "seedRice");
addOre(InitItems.itemFoods, TheFoods.RICE.ordinal(), "cropRice");
addOre(InitItems.itemFlaxSeed, "seedFlax");
addOre(InitItems.itemCanolaSeed.get(), "seedCanola");
addOre(InitItems.itemMisc.get(), TheMiscItems.CANOLA.ordinal(), "cropCanola");
addOre(InitItems.itemRiceSeed.get(), "seedRice");
addOre(InitItems.itemFoods.get(), TheFoods.RICE.ordinal(), "cropRice");
addOre(InitItems.itemFlaxSeed.get(), "seedFlax");
addOre(Items.STRING, "cropFlax");
addOre(InitItems.itemCoffeeSeed, "seedCoffee");
addOre(InitItems.itemCoffeeBean, "cropCoffee");
addOre(InitItems.itemCoffeeSeed.get(), "seedCoffee");
addOre(InitItems.itemCoffeeBean.get(), "cropCoffee");
//For Crafting
addOre(InitItems.itemMisc, TheMiscItems.RICE_SLIME.ordinal(), "slimeball");
addOre(ActuallyBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), "blockCharcoal");
addOre(ActuallyBlocks.blockMisc, TheMiscBlocks.QUARTZ.ordinal(), "blockQuartzBlack");
addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack");
addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dye");
addOre(InitItems.itemMisc.get(), TheMiscItems.RICE_SLIME.ordinal(), "slimeball");
addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), "blockCharcoal");
addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.QUARTZ.ordinal(), "blockQuartzBlack");
addOre(InitItems.itemMisc.get(), TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack");
addOre(InitItems.itemMisc.get(), TheMiscItems.BLACK_DYE.ordinal(), "dye");
}
private static void addOre(Item item, int meta, String name) {
addOre(new ItemStack(item, 1, meta), name);
// addOre(new ItemStack(item, 1, meta), name);
}
private static void addOre(Item item, String name) {
addOre(item, 0, name);
// addOre(item, 0, name);
}
private static void addOre(Block block, int meta, String name) {
addOre(new ItemStack(block, 1, meta), name);
// addOre(new ItemStack(block, 1, meta), name);
}
private static void addOre(ItemStack stack, String name) {
OreDictionary.registerOre(name, stack);
// OreDictionary.registerOre(name, stack);
}
}

View file

@ -5,19 +5,21 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.math.BlockPos;
import java.util.Map;
// TODO: [port][test] check that this works
public class EnchBookConversion extends LensConversionRecipe {
public EnchBookConversion() {
super(Ingredient.fromItem(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion);
super(Ingredient.fromItems(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion);
}
@Override

View file

@ -1,56 +1,57 @@
/*
* This file ("TreasureChestHandler.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.recipe;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
public final class TreasureChestHandler {
public static void init() {
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.DIAMOND), 5, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.IRON_INGOT), 30, 1, 5);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_NUGGET), 60, 1, 8);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_INGOT), 35, 1, 3);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.ENDER_PEARL), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EMERALD), 3, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EXPERIENCE_BOTTLE), 5, 3, 6);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemSolidifiedExperience), 15, 3, 6);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_11), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_13), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_BLOCKS), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CAT), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CHIRP), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_FAR), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MALL), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MELLOHI), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STAL), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STRAD), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WARD), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WAIT), 1, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.SADDLE), 5, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.NAME_TAG), 20, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.GRA_KI_BA.ordinal()), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PL_AP_LE.ordinal()), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CH_AP_CI.ordinal()), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), 10, 1, 2);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH), 80, 1, 3);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 1), 60, 1, 3);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 2), 10, 1, 1);
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 3), 40, 1, 2);
}
}
// TODO: [port][note] no longer required
///*
// * This file ("TreasureChestHandler.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.recipe;
//
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
//import de.ellpeck.actuallyadditions.mod.items.InitItems;
//import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
//import net.minecraft.init.Items;
//import net.minecraft.item.ItemStack;
//
//public final class TreasureChestHandler {
//
// public static void init() {
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.DIAMOND), 5, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.IRON_INGOT), 30, 1, 5);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_NUGGET), 60, 1, 8);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_INGOT), 35, 1, 3);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.ENDER_PEARL), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EMERALD), 3, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EXPERIENCE_BOTTLE), 5, 3, 6);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemSolidifiedExperience), 15, 3, 6);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_11), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_13), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_BLOCKS), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CAT), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CHIRP), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_FAR), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MALL), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MELLOHI), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STAL), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STRAD), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WARD), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WAIT), 1, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.SADDLE), 5, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.NAME_TAG), 20, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.GRA_KI_BA.ordinal()), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PL_AP_LE.ordinal()), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CH_AP_CI.ordinal()), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), 10, 1, 2);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH), 80, 1, 3);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 1), 60, 1, 3);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 2), 10, 1, 1);
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 3), 40, 1, 2);
// }
//
//}

View file

@ -1,89 +1,90 @@
/*
* This file ("TileEntityGiantChest.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.AwfulUtil;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.WorldServer;
import net.minecraft.world.storage.loot.ILootContainer;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootTable;
public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor, ILootContainer {
public ResourceLocation lootTable;
public TileEntityGiantChest(int slotAmount, String name) {
super(slotAmount, name);
}
public TileEntityGiantChest() {
this(9 * 13, "giantChest");
}
@Override
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
super.writeSyncableNBT(compound, type);
if (this.lootTable != null) {
compound.setString("LootTable", this.lootTable.toString());
}
}
@Override
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
super.readSyncableNBT(compound, type);
if (compound.hasKey("LootTable")) {
this.lootTable = new ResourceLocation(compound.getString("LootTable"));
}
}
@Override
public void onButtonPressed(int buttonID, PlayerEntity player) {
if (player != null && this.pos != null) {
GuiHandler.GuiTypes type;
if (buttonID == 0) {
type = GuiHandler.GuiTypes.GIANT_CHEST;
} else if (buttonID == 1) {
type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2;
} else {
type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3;
}
player.openGui(ActuallyAdditions.INSTANCE, type.ordinal(), this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ());
}
}
@Override
public ResourceLocation getLootTable() {
return this.lootTable;
}
public void fillWithLoot(PlayerEntity player) {
if (this.lootTable != null && !this.world.isRemote && this.world instanceof WorldServer) {
LootTable table = this.world.getLootTableManager().getLootTableFromLocation(this.lootTable);
this.lootTable = null;
LootContext.Builder builder = new LootContext.Builder((WorldServer) this.world);
if (player != null) {
builder.withLuck(player.getLuck());
}
AwfulUtil.fillInventory(table, this.inv, this.world.rand, builder.build());
}
}
}
// TODO: [port][note] No longer needed
///*
// * This file ("TileEntityGiantChest.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.tile;
//
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
//import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
//import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
//import de.ellpeck.actuallyadditions.mod.util.AwfulUtil;
//import net.minecraft.entity.player.PlayerEntity;
//import net.minecraft.nbt.CompoundNBT;
//import net.minecraft.util.ResourceLocation;
//import net.minecraft.world.WorldServer;
//import net.minecraft.world.storage.loot.ILootContainer;
//import net.minecraft.world.storage.loot.LootContext;
//import net.minecraft.world.storage.loot.LootTable;
//
//public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor, ILootContainer {
//
// public ResourceLocation lootTable;
//
// public TileEntityGiantChest(int slotAmount, String name) {
// super(slotAmount, name);
// }
//
// public TileEntityGiantChest() {
// this(9 * 13, "giantChest");
// }
//
// @Override
// public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
// super.writeSyncableNBT(compound, type);
//
// if (this.lootTable != null) {
// compound.setString("LootTable", this.lootTable.toString());
// }
// }
//
// @Override
// public void readSyncableNBT(CompoundNBT compound, NBTType type) {
// super.readSyncableNBT(compound, type);
//
// if (compound.hasKey("LootTable")) {
// this.lootTable = new ResourceLocation(compound.getString("LootTable"));
// }
// }
//
// @Override
// public void onButtonPressed(int buttonID, PlayerEntity player) {
// if (player != null && this.pos != null) {
// GuiHandler.GuiTypes type;
//
// if (buttonID == 0) {
// type = GuiHandler.GuiTypes.GIANT_CHEST;
// } else if (buttonID == 1) {
// type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2;
// } else {
// type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3;
// }
//
// player.openGui(ActuallyAdditions.INSTANCE, type.ordinal(), this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ());
// }
// }
//
// @Override
// public ResourceLocation getLootTable() {
// return this.lootTable;
// }
//
// public void fillWithLoot(PlayerEntity player) {
// if (this.lootTable != null && !this.world.isRemote && this.world instanceof WorldServer) {
// LootTable table = this.world.getLootTableManager().getLootTableFromLocation(this.lootTable);
// this.lootTable = null;
//
// LootContext.Builder builder = new LootContext.Builder((WorldServer) this.world);
// if (player != null) {
// builder.withLuck(player.getLuck());
// }
// AwfulUtil.fillInventory(table, this.inv, this.world.rand, builder.build());
// }
// }
//}

View file

@ -17,10 +17,11 @@ import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.OnlyIn;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class UpdateChecker {
@ -46,11 +47,11 @@ public class UpdateChecker {
if (Minecraft.getInstance().player != null) {
PlayerEntity player = Minecraft.getInstance().player;
if (UpdateChecker.checkFailed) {
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.failed")));
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.failed")), false);
} else if (UpdateChecker.needsUpdateNotify) {
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.generic")));
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString)));
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)));
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.generic")), false);
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString)), false);
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)), false);
}
if (threadFinished) {
MinecraftForge.EVENT_BUS.unregister(this);

View file

@ -1,107 +1,109 @@
/*
* This file ("AwfulUtil.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.util;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
//This is stuff copied from somewhere in vanilla and changed so that it works properly
//It's unpolished and vanilla-y, so don't look at it! O_O
public final class AwfulUtil {
public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context) {
List<ItemStack> list = table.generateLootForPools(rand, context);
List<Integer> list1 = getEmptySlotsRandomized(inventory, rand);
shuffleItems(list, list1.size(), rand);
for (ItemStack itemstack : list) {
if (itemstack.isEmpty()) {
inventory.setStackInSlot(list1.remove(list1.size() - 1), ItemStack.EMPTY);
} else {
inventory.setStackInSlot(list1.remove(list1.size() - 1), itemstack);
}
}
}
private static void shuffleItems(List<ItemStack> stacks, int someInt, Random rand) {
List<ItemStack> list = Lists.newArrayList();
Iterator<ItemStack> iterator = stacks.iterator();
while (iterator.hasNext()) {
ItemStack itemstack = iterator.next();
if (itemstack.isEmpty()) {
iterator.remove();
} else if (itemstack.getCount() > 1) {
list.add(itemstack);
iterator.remove();
}
}
someInt = someInt - stacks.size();
while (someInt > 0 && list.size() > 0) {
ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2);
ItemStack itemstack1 = itemstack2.splitStack(i);
if (itemstack2.getCount() > 1 && rand.nextBoolean()) {
list.add(itemstack2);
} else {
stacks.add(itemstack2);
}
if (itemstack1.getCount() > 1 && rand.nextBoolean()) {
list.add(itemstack1);
} else {
stacks.add(itemstack1);
}
}
stacks.addAll(list);
Collections.shuffle(stacks, rand);
}
private static List<Integer> getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand) {
List<Integer> list = Lists.newArrayList();
for (int i = 0; i < inventory.getSlots(); ++i) {
if (inventory.getStackInSlot(i).isEmpty()) {
list.add(i);
}
}
Collections.shuffle(list, rand);
return list;
}
public static void callTheFuckinPolice(Object... stuff) {
int i = 0;
String error = "Actually Additions: Something is very wrong. This method was provided with ";
for (Object k : stuff) {
error += "\n" + i++ + ": " + (k == null ? "null" : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ");
}
error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide();
error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
throw new IllegalStateException(error);
}
}
// TODO: [port][note] no longer used
///*
// * This file ("AwfulUtil.java") is part of the Actually Additions mod for Minecraft.
// * It is created and owned by Ellpeck and distributed
// * under the Actually Additions License to be found at
// * http://ellpeck.de/actaddlicense
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
// *
// * © 2015-2017 Ellpeck
// */
//
//package de.ellpeck.actuallyadditions.mod.util;
//
//import com.google.common.collect.Lists;
//import net.minecraft.item.ItemStack;
//import net.minecraft.loot.LootContext;
//import net.minecraft.loot.LootTable;
//import net.minecraft.util.math.MathHelper;
//import net.minecraftforge.fml.loading.FMLLoader;
//import net.minecraftforge.items.IItemHandlerModifiable;
//
//import java.util.Collections;
//import java.util.Iterator;
//import java.util.List;
//import java.util.Random;
//
////This is stuff copied from somewhere in vanilla and changed so that it works properly
////It's unpolished and vanilla-y, so don't look at it! O_O
//public final class AwfulUtil {
//
// public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context) {
// List<ItemStack> list = table.generateLootForPools(rand, context);
// List<Integer> list1 = getEmptySlotsRandomized(inventory, rand);
// shuffleItems(list, list1.size(), rand);
//
// for (ItemStack itemstack : list) {
// if (itemstack.isEmpty()) {
// inventory.setStackInSlot(list1.remove(list1.size() - 1), ItemStack.EMPTY);
// } else {
// inventory.setStackInSlot(list1.remove(list1.size() - 1), itemstack);
// }
// }
// }
//
// private static void shuffleItems(List<ItemStack> stacks, int someInt, Random rand) {
// List<ItemStack> list = Lists.newArrayList();
// Iterator<ItemStack> iterator = stacks.iterator();
//
// while (iterator.hasNext()) {
// ItemStack itemstack = iterator.next();
//
// if (itemstack.isEmpty()) {
// iterator.remove();
// } else if (itemstack.getCount() > 1) {
// list.add(itemstack);
// iterator.remove();
// }
// }
//
// someInt = someInt - stacks.size();
//
// while (someInt > 0 && list.size() > 0) {
// ItemStack itemstack2 = list.remove(MathHelper.nextInt(rand, 0, list.size() - 1));
// int i = MathHelper.nextInt(rand, 1, itemstack2.getCount() / 2);
// ItemStack itemstack1 = itemstack2.split(i);
//
// if (itemstack2.getCount() > 1 && rand.nextBoolean()) {
// list.add(itemstack2);
// } else {
// stacks.add(itemstack2);
// }
//
// if (itemstack1.getCount() > 1 && rand.nextBoolean()) {
// list.add(itemstack1);
// } else {
// stacks.add(itemstack1);
// }
// }
//
// stacks.addAll(list);
// Collections.shuffle(stacks, rand);
// }
//
// private static List<Integer> getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand) {
// List<Integer> list = Lists.newArrayList();
//
// for (int i = 0; i < inventory.getSlots(); ++i) {
// if (inventory.getStackInSlot(i).isEmpty()) {
// list.add(i);
// }
// }
//
// Collections.shuffle(list, rand);
// return list;
// }
//
// public static void callTheFuckinPolice(Object... stuff) {
// int i = 0;
// String error = "Actually Additions: Something is very wrong. This method was provided with ";
// for (Object k : stuff) {
// error += "\n" + i++ + ": " + (k == null
// ? "null"
// : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ");
// }
// error += "\n" + "The current side is: " + FMLLoader.getDist().name();
// error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
// throw new IllegalStateException(error);
// }
//}

View file

@ -10,24 +10,16 @@
package de.ellpeck.actuallyadditions.mod.util;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.RegistryHandler;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.compat.IMCHandler;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistries;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public final class ItemUtil {
@ -35,105 +27,51 @@ public final class ItemUtil {
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
}
public static void registerBlock(Block block, ItemBlockBase itemBlock, String name, boolean addTab) {
block.setTranslationKey(ActuallyAdditions.MODID + "." + name);
block.setRegistryName(ActuallyAdditions.MODID, name);
RegistryHandler.BLOCKS_TO_REGISTER.add(block);
itemBlock.setRegistryName(block.getRegistryName());
RegistryHandler.ITEMS_TO_REGISTER.add(itemBlock);
block.setCreativeTab(addTab
? CreativeTab.INSTANCE
: null);
IMCHandler.doBlockIMC(block);
if (block instanceof IColorProvidingBlock) {
ActuallyAdditions.PROXY.addColoredBlock(block);
}
}
public static void registerItem(Item item, String name, boolean addTab) {
item.setTranslationKey(ActuallyAdditions.MODID + "." + name);
item.setRegistryName(ActuallyAdditions.MODID, name);
RegistryHandler.ITEMS_TO_REGISTER.add(item);
item.setCreativeTab(addTab
? CreativeTab.INSTANCE
: null);
IMCHandler.doItemIMC(item);
if (item instanceof IColorProvidingItem) {
ActuallyAdditions.PROXY.addColoredItem(item);
}
}
public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
return getPlaceAt(array, stack, checkWildcard) != -1;
}
public static int getPlaceAt(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
return getPlaceAt(Arrays.asList(array), stack, checkWildcard);
}
public static int getPlaceAt(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
if (!StackUtil.isValid(stack) && !StackUtil.isValid(list.get(i)) || areItemsEqual(stack, list.get(i), checkWildcard)) {
return i;
}
}
}
return -1;
}
// public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
// return getPlaceAt(array, stack, checkWildcard) != -1;
// }
//
// public static int getPlaceAt(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
// return getPlaceAt(Arrays.asList(array), stack, checkWildcard);
// }
//
// public static int getPlaceAt(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
// if (list != null && list.size() > 0) {
// for (int i = 0; i < list.size(); i++) {
// if (!StackUtil.isValid(stack) && !StackUtil.isValid(list.get(i)) || areItemsEqual(stack, list.get(i), checkWildcard)) {
// return i;
// }
// }
// }
// return -1;
// }
@Deprecated
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard) {
return StackUtil.isValid(stack1) && StackUtil.isValid(stack2) && (stack1.isItemEqual(stack2) || checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD));
return stack1.isItemEqual(stack2);
//return StackUtil.isValid(stack1) && StackUtil.isValid(stack2) && (stack1.isItemEqual(stack2) || checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD));
}
/**
* Returns true if list contains stack or if both contain null
*/
public static boolean contains(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
return !(list == null || list.isEmpty()) && getPlaceAt(list, stack, checkWildcard) != -1;
}
// /**
// * Returns true if list contains stack or if both contain null
// */
// public static boolean contains(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
// return !(list == null || list.isEmpty()) && getPlaceAt(list, stack, checkWildcard) != -1;
// }
@Deprecated
public static void addEnchantment(ItemStack stack, Enchantment e, int level) {
if (!hasEnchantment(stack, e)) {
if (!EnchantmentHelper.getEnchantments(stack).containsKey(e)) {
stack.addEnchantment(e, level);
}
}
public static boolean hasEnchantment(ItemStack stack, Enchantment e) {
ListNBT ench = stack.getEnchantmentTagList();
if (ench != null) {
for (int i = 0; i < ench.size(); i++) {
short id = ench.getCompound(i).getShort("id");
if (id == Enchantment.getEnchantmentID(e)) {
return true;
}
}
}
return false;
}
// TODO: [port] ensure this still works :D
public static void removeEnchantment(ItemStack stack, Enchantment e) {
ListNBT ench = stack.getEnchantmentTagList();
if (ench != null) {
for (int i = 0; i < ench.size(); i++) {
short id = ench.getCompound(i).getShort("id");
if (id == Enchantment.getEnchantmentID(e)) {
ench.removeTag(i);
}
}
if (ench.isEmpty() && stack.hasTagCompound()) {
stack.getTagCompound().removeTag("ench");
}
}
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
enchantments.remove(e);
EnchantmentHelper.setEnchantments(enchantments, stack);
}
public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) {
@ -141,7 +79,7 @@ public final class ItemUtil {
}
public static boolean isEnabled(ItemStack stack) {
return stack.hasTagCompound() && stack.getTagCompound().getBoolean("IsEnabled");
return stack.getOrCreateTag().getBoolean("IsEnabled");
}
public static void changeEnabled(PlayerEntity player, Hand hand) {
@ -149,11 +87,7 @@ public final class ItemUtil {
}
public static void changeEnabled(ItemStack stack) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new CompoundNBT());
}
boolean isEnabled = isEnabled(stack);
stack.getTagCompound().putBoolean("IsEnabled", !isEnabled);
stack.getOrCreateTag().putBoolean("IsEnabled", !isEnabled);
}
}

View file

@ -1,26 +0,0 @@
package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.IRarity;
public class Rarity implements IRarity {
TextFormatting color;
String name;
public Rarity(TextFormatting color, String name) {
this.color = color;
this.name = name;
}
@Override
public TextFormatting getColor() {
return color;
}
@Override
public String getName() {
return name;
}
}

View file

@ -1,20 +1,17 @@
package de.ellpeck.actuallyadditions.mod.util;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import net.minecraftforge.fml.loading.FMLLoader;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.StringJoiner;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
public class RefHelp {
public static class UnableToFindMethodException extends RuntimeException {
@ -62,7 +59,7 @@ public class RefHelp {
}
public static class UnknownConstructorException extends RuntimeException {
public UnknownConstructorException(final String message) {
public UnknownConstructorException(String message) {
super(message);
}
}
@ -86,7 +83,9 @@ public class RefHelp {
Preconditions.checkNotNull(clazz);
Preconditions.checkArgument(StringUtils.isNotEmpty(fieldName), "Field name cannot be empty");
String nameToFind = FMLLaunchHandler.isDeobfuscatedEnvironment() ? fieldName : MoreObjects.firstNonNull(fieldObfName, fieldName);
String nameToFind = !FMLLoader.isProduction()
? fieldName
: MoreObjects.firstNonNull(fieldObfName, fieldName);
try {
Field f = clazz.getDeclaredField(nameToFind);
@ -177,6 +176,7 @@ public class RefHelp {
* @param methodObfName The obfuscated name of the method to find (used in obfuscated environments, i.e. "getWorldTime").
* If the name you are looking for is on a class that is never obfuscated, this should be null.
* @param parameterTypes The parameter types of the method to find.
*
* @return The method with the specified name and parameters in the given class.
*/
@Nonnull
@ -184,7 +184,10 @@ public class RefHelp {
Preconditions.checkNotNull(clazz);
Preconditions.checkArgument(StringUtils.isNotEmpty(methodName), "Method name cannot be empty");
String nameToFind = FMLLaunchHandler.isDeobfuscatedEnvironment() ? methodName : MoreObjects.firstNonNull(methodObfName, methodName);
// TODO: [port][note] this might be wrong.
String nameToFind = !FMLLoader.isProduction()
? methodName
: MoreObjects.firstNonNull(methodObfName, methodName);
try {
Method m = clazz.getDeclaredMethod(nameToFind, parameterTypes);
@ -198,16 +201,18 @@ public class RefHelp {
/**
* Finds a constructor in the specified class that has matching parameter types.
*
* @param klass The class to find the constructor in
* @param klass The class to find the constructor in
* @param parameterTypes The parameter types of the constructor.
* @param <T> The type
* @param <T> The type
*
* @return The constructor
* @throws NullPointerException if {@code klass} is null
* @throws NullPointerException if {@code parameterTypes} is null
*
* @throws NullPointerException if {@code klass} is null
* @throws NullPointerException if {@code parameterTypes} is null
* @throws UnknownConstructorException if the constructor could not be found
*/
@Nonnull
public static <T> Constructor<T> findConstructor(@Nonnull final Class<T> klass, @Nonnull final Class<?>... parameterTypes) {
public static <T> Constructor<T> findConstructor(@Nonnull Class<T> klass, @Nonnull Class<?>... parameterTypes) {
Preconditions.checkNotNull(klass, "class");
Preconditions.checkNotNull(parameterTypes, "parameter types");
@ -215,8 +220,8 @@ public class RefHelp {
Constructor<T> constructor = klass.getDeclaredConstructor(parameterTypes);
constructor.setAccessible(true);
return constructor;
} catch (final NoSuchMethodException e) {
final StringBuilder desc = new StringBuilder();
} catch (NoSuchMethodException e) {
StringBuilder desc = new StringBuilder();
desc.append(klass.getSimpleName());
StringJoiner joiner = new StringJoiner(", ", "(", ")");
@ -228,4 +233,4 @@ public class RefHelp {
throw new UnknownConstructorException("Could not find constructor '" + desc.toString() + "' in " + klass);
}
}
}
}

View file

@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapp
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.items.IItemHandler;
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
import java.util.Collection;
import java.util.List;
@ -29,6 +28,7 @@ public final class StackUtil {
*
* @return If the stack is not empty, or if it's an IDisableableItem, if its enabled.
*/
@Deprecated
public static boolean isValid(ItemStack stack) {
return stack != null && !stack.isEmpty();
// if (stack == null) AwfulUtil.callTheFuckinPolice("Null ItemStack detected", stack);
@ -40,21 +40,11 @@ public final class StackUtil {
/**
* @return The empty itemstack instance.
*/
@Deprecated
public static ItemStack getEmpty() {
return ItemStack.EMPTY;
}
/**
* A helper method to make NonNullLists with empty fill.
*
* @param size How big the list will be.
*
* @return A {@link NonNullList} with the same size as provided.
*/
public static NonNullList<ItemStack> makeList(int size) {
return NonNullList.withSize(size, getEmpty());
}
/**
* Checks if a collection of stacks are empty, as {@link Collection#isEmpty()} does not care about empty stacks.
*
@ -62,6 +52,7 @@ public final class StackUtil {
*
* @return If all stacks in the collection return true for {@link ItemStack#isEmpty()}
*/
@Deprecated
public static boolean isEmpty(Collection<ItemStack> stacks) {
if (stacks.isEmpty()) {
return true;
@ -230,12 +221,12 @@ public final class StackUtil {
if (ActuallyAdditions.commonCapsLoaded) {
Object handler = wrapper.getSlotlessHandler();
if (handler instanceof ISlotlessItemHandler) {
remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
if (!ItemStack.areItemStacksEqual(remain, stack)) {
return remain;
}
}
// if (handler instanceof ISlotlessItemHandler) {
// remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
// if (!ItemStack.areItemStacksEqual(remain, stack)) {
// return remain;
// }
// }
}
IItemHandler handler = wrapper.getNormalHandler();

View file

@ -10,18 +10,18 @@
package de.ellpeck.actuallyadditions.mod.util;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.LanguageMap;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.OnlyIn;
public final class StringUtil {
public static final int DECIMAL_COLOR_WHITE = 16777215;
@ -45,7 +45,8 @@ public final class StringUtil {
return I18n.format(text, replace);
}
@SuppressWarnings("deprecation") //TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName
@SuppressWarnings("deprecation")
//TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName
public static String localizeIllegallyOnTheServerDontUseMePls(String langKey) {
return net.minecraft.util.text.translation.I18n.translateToLocal(langKey);
}

View file

@ -11,36 +11,22 @@
package de.ellpeck.actuallyadditions.mod.util;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.IRarity;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fml.loading.FMLLoader;
public final class Util {
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
public static final int BUCKET = Fluid.BUCKET_VOLUME;
@Deprecated
public static final int WILDCARD = Short.MAX_VALUE;//OreDictionary.WILDCARD_VALUE;
public static final IRarity CRYSTAL_RED_RARITY = addRarity("crystalRed", TextFormatting.DARK_RED, ActuallyAdditions.NAME + " Red Crystal");
public static final IRarity CRYSTAL_BLUE_RARITY = addRarity("crystalBlue", TextFormatting.DARK_BLUE, ActuallyAdditions.NAME + " Blue Crystal");
public static final IRarity CRYSTAL_LIGHT_BLUE_RARITY = addRarity("crystalLightBlue", TextFormatting.BLUE, ActuallyAdditions.NAME + " Light Blue Crystal");
public static final IRarity CRYSTAL_BLACK_RARITY = addRarity("crystalBlack", TextFormatting.DARK_GRAY, ActuallyAdditions.NAME + " Black Crystal");
public static final IRarity CRYSTAL_GREEN_RARITY = addRarity("crystalGreen", TextFormatting.DARK_GREEN, ActuallyAdditions.NAME + " Green Crystal");
public static final IRarity CRYSTAL_WHITE_RARITY = addRarity("crystalWhite", TextFormatting.GRAY, ActuallyAdditions.NAME + " White Crystal");
public static final IRarity FALLBACK_RARITY = addRarity("fallback", TextFormatting.STRIKETHROUGH, ActuallyAdditions.NAME + " Fallback");
private static IRarity addRarity(String name, TextFormatting color, String displayName) {
return new Rarity(color, displayName);
}
@Deprecated
public static final int BUCKET = 1000;
public static boolean isDevVersion() {
return ActuallyAdditions.VERSION.equals("@VERSION@");
}
public static boolean isClient() {
return FMLCommonHandler.instance().getEffectiveSide().isClient();
return FMLLoader.getDist().isClient();
}
private static String[] splitVersion() {
@ -54,4 +40,4 @@ public final class Util {
public static String getMajorModVersion() {
return splitVersion()[1].substring(1);
}
}
}

View file

@ -1,17 +1,16 @@
package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.server.ServerWorld;
public final class VanillaPacketDispatcher {
//Don't call from the client.
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
WorldServer world = (WorldServer) tile.getWorld();
ServerWorld world = (ServerWorld) tile.getWorld();
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4);
if (entry == null) {