mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
chore: utils mostly ported, misc ported, deprecation's added, specials ported mostly
This commit is contained in:
parent
6f34f82f4e
commit
cb650b6689
44 changed files with 1001 additions and 1285 deletions
|
@ -1,188 +1,189 @@
|
||||||
/*
|
// 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
|
// * This file ("BlockGiantChest.java") is part of the Actually Additions mod for Minecraft.
|
||||||
* under the Actually Additions License to be found at
|
// * It is created and owned by Ellpeck and distributed
|
||||||
* http://ellpeck.de/actaddlicense
|
// * under the Actually Additions License to be found at
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
// * http://ellpeck.de/actaddlicense
|
||||||
*
|
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
* © 2015-2017 Ellpeck
|
// *
|
||||||
*/
|
// * © 2015-2017 Ellpeck
|
||||||
|
// */
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
//
|
||||||
|
//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.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
//import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
//import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
//import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
//import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
//import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
//import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.SoundType;
|
//import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
//import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
//import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
//import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
//import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.item.EnumRarity;
|
//import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
//import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.ListNBT;
|
//import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
//import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.util.Hand;
|
//import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.NonNullList;
|
//import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
//import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
//import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
//import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.world.World;
|
//import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
//import net.minecraft.world.World;
|
||||||
|
//import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import java.util.List;
|
//
|
||||||
|
//import java.util.List;
|
||||||
public class BlockGiantChest extends BlockContainerBase {
|
//
|
||||||
|
//public class BlockGiantChest extends BlockContainerBase {
|
||||||
public final int type;
|
//
|
||||||
|
// public final int type;
|
||||||
public BlockGiantChest(String name, int type) {
|
//
|
||||||
super(Material.WOOD, name);
|
// public BlockGiantChest(String name, int type) {
|
||||||
this.type = type;
|
// super(Material.WOOD, name);
|
||||||
|
// this.type = type;
|
||||||
this.setHarvestLevel("axe", 0);
|
//
|
||||||
this.setHardness(0.5F);
|
// this.setHarvestLevel("axe", 0);
|
||||||
this.setResistance(15.0F);
|
// this.setHardness(0.5F);
|
||||||
this.setSoundType(SoundType.WOOD);
|
// this.setResistance(15.0F);
|
||||||
|
// this.setSoundType(SoundType.WOOD);
|
||||||
}
|
//
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
// @Override
|
||||||
switch (this.type) {
|
// public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||||
case 1:
|
// switch (this.type) {
|
||||||
return new TileEntityGiantChestMedium();
|
// case 1:
|
||||||
case 2:
|
// return new TileEntityGiantChestMedium();
|
||||||
return new TileEntityGiantChestLarge();
|
// case 2:
|
||||||
default:
|
// return new TileEntityGiantChestLarge();
|
||||||
return new TileEntityGiantChest();
|
// default:
|
||||||
}
|
// return new TileEntityGiantChest();
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean isFullCube(BlockState state) {
|
// @Override
|
||||||
return false;
|
// public boolean isFullCube(BlockState state) {
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
// @Override
|
||||||
return false;
|
// public boolean isOpaqueCube(BlockState state) {
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
// @Override
|
||||||
if (!world.isRemote) {
|
// public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
|
// if (!world.isRemote) {
|
||||||
if (chest != null) {
|
// TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
|
||||||
chest.fillWithLoot(player);
|
// if (chest != null) {
|
||||||
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
// chest.fillWithLoot(player);
|
||||||
}
|
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
return true;
|
// }
|
||||||
}
|
// return true;
|
||||||
return true;
|
// }
|
||||||
}
|
// return true;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public EnumRarity getRarity(ItemStack stack) {
|
// @Override
|
||||||
return EnumRarity.EPIC;
|
// public EnumRarity getRarity(ItemStack stack) {
|
||||||
}
|
// return EnumRarity.EPIC;
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase entity, ItemStack stack) {
|
// @Override
|
||||||
if (stack.getTagCompound() != null) {
|
// public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase entity, ItemStack stack) {
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
// if (stack.getTagCompound() != null) {
|
||||||
if (tile instanceof TileEntityGiantChest) {
|
// TileEntity tile = world.getTileEntity(pos);
|
||||||
ListNBT list = stack.getTagCompound().getList("Items", 10);
|
// if (tile instanceof TileEntityGiantChest) {
|
||||||
IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv;
|
// 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);
|
// for (int i = 0; i < list.size(); i++) {
|
||||||
if (compound != null && compound.hasKey("id")) {
|
// CompoundNBT compound = list.getCompound(i);
|
||||||
inv.setStackInSlot(i, new ItemStack(list.getCompound(i)));
|
// if (compound != null && compound.hasKey("id")) {
|
||||||
}
|
// inv.setStackInSlot(i, new ItemStack(list.getCompound(i)));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
super.onBlockPlacedBy(world, pos, state, entity, stack);
|
//
|
||||||
}
|
// super.onBlockPlacedBy(world, pos, state, entity, stack);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
// @Override
|
||||||
super.getDrops(drops, world, pos, state, fortune);
|
// public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
// super.getDrops(drops, world, pos, state, fortune);
|
||||||
if (tile instanceof TileEntityGiantChest) {
|
// TileEntity tile = world.getTileEntity(pos);
|
||||||
ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv;
|
// if (tile instanceof TileEntityGiantChest) {
|
||||||
int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
// ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv;
|
||||||
if (place >= 0) {
|
// int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
||||||
ListNBT list = new ListNBT();
|
// if (place >= 0) {
|
||||||
for (int i = 0; i < slots.getSlots(); i++) {
|
// ListNBT list = new ListNBT();
|
||||||
//Destroy the keeper
|
// for (int i = 0; i < slots.getSlots(); i++) {
|
||||||
if (i != place) {
|
// //Destroy the keeper
|
||||||
CompoundNBT compound = new CompoundNBT();
|
// if (i != place) {
|
||||||
if (StackUtil.isValid(slots.getStackInSlot(i))) {
|
// CompoundNBT compound = new CompoundNBT();
|
||||||
slots.getStackInSlot(i).writeToNBT(compound);
|
// if (StackUtil.isValid(slots.getStackInSlot(i))) {
|
||||||
}
|
// slots.getStackInSlot(i).writeToNBT(compound);
|
||||||
list.appendTag(compound);
|
// }
|
||||||
}
|
// list.appendTag(compound);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (list.size() > 0) {
|
//
|
||||||
ItemStack stackInQuestion = drops.get(0);
|
// if (list.size() > 0) {
|
||||||
if (StackUtil.isValid(stackInQuestion)) {
|
// ItemStack stackInQuestion = drops.get(0);
|
||||||
if (stackInQuestion.getTagCompound() == null) {
|
// if (StackUtil.isValid(stackInQuestion)) {
|
||||||
stackInQuestion.setTagCompound(new CompoundNBT());
|
// if (stackInQuestion.getTagCompound() == null) {
|
||||||
}
|
// stackInQuestion.setTagCompound(new CompoundNBT());
|
||||||
stackInQuestion.getTagCompound().setTag("Items", list);
|
// }
|
||||||
}
|
// stackInQuestion.getTagCompound().setTag("Items", list);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public boolean shouldDropInventory(World world, BlockPos pos) {
|
// @Override
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
// public boolean shouldDropInventory(World world, BlockPos pos) {
|
||||||
return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
// TileEntity tile = world.getTileEntity(pos);
|
||||||
}
|
// return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
protected ItemBlockBase getItemBlock() {
|
// @Override
|
||||||
return new TheItemBlock(this);
|
// protected ItemBlockBase getItemBlock() {
|
||||||
}
|
// return new TheItemBlock(this);
|
||||||
|
// }
|
||||||
public static class TheItemBlock extends ItemBlockBase {
|
//
|
||||||
|
// public static class TheItemBlock extends ItemBlockBase {
|
||||||
public TheItemBlock(Block block) {
|
//
|
||||||
super(block);
|
// public TheItemBlock(Block block) {
|
||||||
}
|
// super(block);
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
// @Override
|
||||||
int type = this.block instanceof BlockGiantChest
|
// public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
||||||
? ((BlockGiantChest) this.block).type
|
// int type = this.block instanceof BlockGiantChest
|
||||||
: -1;
|
// ? ((BlockGiantChest) this.block).type
|
||||||
if (type == 2) {
|
// : -1;
|
||||||
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChestLarge.desc"));
|
// if (type == 2) {
|
||||||
} else if (type == 0) {
|
// tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChestLarge.desc"));
|
||||||
tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChest.desc"));
|
// } else if (type == 0) {
|
||||||
}
|
// tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container." + ActuallyAdditions.MODID + ".giantChest.desc"));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public CompoundNBT getNBTShareTag(ItemStack stack) {
|
// @Override
|
||||||
return null;
|
// public CompoundNBT getNBTShareTag(ItemStack stack) {
|
||||||
}
|
// return null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
@ -20,30 +19,9 @@ import net.minecraftforge.fluids.Fluid;
|
||||||
|
|
||||||
public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity {
|
public class BlockFluidFlowing extends BlockFluidClassic implements ItemBlockBase.ICustomRarity {
|
||||||
|
|
||||||
private final String name;
|
public BlockFluidFlowing(Fluid fluid, Material material) {
|
||||||
|
|
||||||
public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName) {
|
|
||||||
super(fluid, material);
|
super(fluid, material);
|
||||||
this.name = unlocalizedName;
|
|
||||||
this.displacements.put(this, false);
|
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
|
@Override
|
||||||
|
|
|
@ -10,33 +10,15 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||||
public class ActuallyContainers {
|
public class ActuallyContainers {
|
||||||
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MODID);
|
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, ActuallyAdditions.MODID);
|
||||||
|
|
||||||
public static final RegistryObject<ContainerType<ContainerBag>> BAG_CONTAINER
|
public static final RegistryObject<ContainerType<ContainerBag>> BAG_CONTAINER = CONTAINERS.register("bag_container", () -> IForgeContainerType.create(ContainerBag::fromNetwork));
|
||||||
= 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<ContainerBioReactor>> BIO_REACTOR_CONTAINER
|
public static final RegistryObject<ContainerType<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER = CONTAINERS.register("canola_press_container", () -> IForgeContainerType.create(ContainerCanolaPress::fromNetwork));
|
||||||
= CONTAINERS.register("bioreactor_container", () -> IForgeContainerType.create(ContainerBioReactor::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<ContainerBreaker>> BREAKER_CONTAINER
|
public static final RegistryObject<ContainerType<ContainerDirectionalBreaker>> DIRECTIONAL_BREAKER_CONTAINER = CONTAINERS.register("directional_breaker_container", () -> IForgeContainerType.create(ContainerDirectionalBreaker::fromNetwork));
|
||||||
= CONTAINERS.register("breaker_container", () -> IForgeContainerType.create(ContainerBreaker::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<ContainerCanolaPress>> CANOLA_PRESS_CONTAINER
|
public static final RegistryObject<ContainerType<ContainerEnergizer>> ENERGIZER_CONTAINER = CONTAINERS.register("energizer_container", () -> IForgeContainerType.create(ContainerEnergizer::fromNetwork));
|
||||||
= 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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> itemMisc = ITEMS.register("item_misc", ItemBase::new);
|
||||||
public static final RegistryObject<Item> itemCanola = ITEMS.register("canola", 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> itemCoffeeCup = ITEMS.register("coffee_cup", ItemBase::new);
|
||||||
|
public static final RegistryObject<Item> itemPaperCone = ITEMS.register("paper_cone", ItemBase::new);
|
||||||
|
|
||||||
// SHARDS
|
// SHARDS
|
||||||
public static final RegistryObject<Item> RESTONIA_CRYSTAL_SHARD = ITEMS.register("item_restonia_crystal_shard", ItemBase::new);
|
public static final RegistryObject<Item> RESTONIA_CRYSTAL_SHARD = ITEMS.register("item_restonia_crystal_shard", ItemBase::new);
|
||||||
|
@ -60,7 +61,6 @@ public final class InitItems {
|
||||||
// BLACK QUARTZ
|
// BLACK QUARTZ
|
||||||
public static final RegistryObject<Item> BLACK_QUARTZ = ITEMS.register("black_quartz", ItemBase::new);
|
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> 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> itemEngineerGoggles = ITEMS.register("item_engineer_goggles", () -> new ItemEngineerGoggles(false));
|
||||||
public static final RegistryObject<Item> itemLaserUpgradeRange = ITEMS.register("item_laser_upgrade_range", ItemBase::new);
|
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> 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> 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> 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> itemBattery = ITEMS.register("item_battery", new ItemBattery(200000, 1000));
|
||||||
public static final RegistryObject<Item> itemBatteryDouble = ITEMS.register("", new ItemBattery("item_battery_double", 350000, 5000));
|
public static final RegistryObject<Item> itemBatteryDouble = ITEMS.register("item_battery_double", new ItemBattery(350000, 5000));
|
||||||
public static final RegistryObject<Item> itemBatteryTriple = ITEMS.register("", new ItemBattery("item_battery_triple", 600000, 10000));
|
public static final RegistryObject<Item> itemBatteryTriple = ITEMS.register("item_battery_triple", new ItemBattery(600000, 10000));
|
||||||
public static final RegistryObject<Item> itemBatteryQuadruple = ITEMS.register("", new ItemBattery("item_battery_quadruple", 1000000, 30000));
|
public static final RegistryObject<Item> itemBatteryQuadruple = ITEMS.register("item_battery_quadruple", new ItemBattery(1000000, 30000));
|
||||||
public static final RegistryObject<Item> itemBatteryQuintuple = ITEMS.register("", new ItemBattery("item_battery_quintuple", 2000000, 100000));
|
public static final RegistryObject<Item> itemBatteryQuintuple = ITEMS.register("item_battery_quintuple", new ItemBattery(2000000, 100000));
|
||||||
public static final RegistryObject<Item> itemDrillUpgradeSpeed = ITEMS.register("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED, "item_drill_upgrade_speed"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II, "item_drill_upgrade_speed_ii"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_III, "item_drill_upgrade_speed_iii"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SILK_TOUCH, "item_drill_upgrade_silk_touch"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE, "item_drill_upgrade_fortune"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE_II, "item_drill_upgrade_fortune_ii"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.THREE_BY_THREE, "item_drill_upgrade_three_by_three"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE, "item_drill_upgrade_five_by_five"));
|
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("", new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.PLACER, "item_drill_upgrade_block_placing"));
|
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> itemFertilizer = ITEMS.register("item_fertilizer", ItemFertilizer::new);
|
||||||
public static final RegistryObject<Item> itemCoffee = ITEMS.register("item_coffee", ItemCoffee::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);
|
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> 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> 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> 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> itemLeafBlower = ITEMS.register("item_leaf_blower", new ItemLeafBlower(false));
|
||||||
public static final RegistryObject<Item> itemLeafBlowerAdvanced = ITEMS.register("", new ItemLeafBlower(true, "item_leaf_blower_advanced"));
|
public static final RegistryObject<Item> itemLeafBlowerAdvanced = ITEMS.register("item_leaf_blower_advanced", new ItemLeafBlower(true));
|
||||||
public static final RegistryObject<Item> itemPotionRing = ITEMS.register("", new ItemPotionRing(false, "item_potion_ring"));
|
public static final RegistryObject<Item> itemPotionRing = ITEMS.register("item_potion_ring", new ItemPotionRing(false));
|
||||||
public static final RegistryObject<Item> itemPotionRingAdvanced = ITEMS.register("", new ItemPotionRing(true, "item_potion_ring_advanced"));
|
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> 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> 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()));
|
public static final RegistryObject<Item> itemRiceSeed = ITEMS.register("", new ItemSeed("item_rice_seed", "seedRice", ActuallyBlocks.blockRice, itemFoods, TheFoods.RICE.ordinal()));
|
||||||
|
|
|
@ -10,37 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
package de.ellpeck.actuallyadditions.mod.items.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
public class ItemFoodBase extends ItemBase {
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
public ItemFoodBase(int heal, float saturation, boolean wolfFood) {
|
||||||
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) {
|
|
||||||
super(heal, saturation, 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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
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.blocks.base.BlockPlant;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemSeedFood;
|
import net.minecraft.item.ItemSeedFood;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -39,14 +37,6 @@ public class ItemFoodSeed extends ItemSeedFood {
|
||||||
if (plant instanceof BlockPlant) {
|
if (plant instanceof BlockPlant) {
|
||||||
((BlockPlant) plant).doStuff(this, returnItem, returnMeta);
|
((BlockPlant) plant).doStuff(this, returnItem, returnMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void register() {
|
|
||||||
ItemUtil.registerItem(this, this.getBaseName(), this.shouldAddCreative());
|
|
||||||
|
|
||||||
this.registerRendering();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,23 +44,6 @@ public class ItemFoodSeed extends ItemSeedFood {
|
||||||
return this.maxUseDuration;
|
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
|
@Override
|
||||||
public BlockState getPlant(IBlockAccess world, BlockPos pos) {
|
public BlockState getPlant(IBlockAccess world, BlockPos pos) {
|
||||||
return this.plant.getDefaultState();
|
return this.plant.getDefaultState();
|
||||||
|
|
|
@ -11,29 +11,21 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
package de.ellpeck.actuallyadditions.mod.items.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
|
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.config.ConfigurationHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.item.HoeItem;
|
import net.minecraft.item.HoeItem;
|
||||||
import net.minecraft.item.IItemTier;
|
import net.minecraft.item.IItemTier;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.IRarity;
|
|
||||||
|
|
||||||
public class ItemHoeAA extends HoeItem implements IDisableableItem {
|
public class ItemHoeAA extends HoeItem implements IDisableableItem {
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final IRarity rarity;
|
|
||||||
private final ItemStack repairItem;
|
private final ItemStack repairItem;
|
||||||
private final boolean disabled;
|
private final boolean disabled;
|
||||||
|
|
||||||
public ItemHoeAA(IItemTier toolMat) {
|
public ItemHoeAA(IItemTier toolMat) {
|
||||||
super(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.");
|
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) {
|
if (!this.disabled) {
|
||||||
this.register();
|
this.register();
|
||||||
|
@ -41,26 +33,6 @@ public class ItemHoeAA extends HoeItem implements IDisableableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void 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 IRarity getForgeRarity(ItemStack stack) {
|
|
||||||
return this.rarity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,58 +10,28 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
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.blocks.base.BlockPlant;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemSeeds;
|
import net.minecraft.item.ItemSeeds;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
public class ItemSeed extends ItemSeeds {
|
public class ItemSeed extends ItemSeeds {
|
||||||
|
|
||||||
public final Block plant;
|
public final Block plant;
|
||||||
public final String name;
|
|
||||||
public final String oredictName;
|
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);
|
super(plant, Blocks.FARMLAND);
|
||||||
this.name = name;
|
|
||||||
this.oredictName = oredictName;
|
this.oredictName = oredictName;
|
||||||
this.plant = plant;
|
this.plant = plant;
|
||||||
|
|
||||||
if (plant instanceof BlockPlant) {
|
if (plant instanceof BlockPlant) {
|
||||||
((BlockPlant) plant).doStuff(this, returnItem, returnMeta);
|
((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
|
@Override
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
package de.ellpeck.actuallyadditions.mod.items.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
|
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.blocks.base.ItemBlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
|
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
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.IItemTier;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.SwordItem;
|
import net.minecraft.item.SwordItem;
|
||||||
import net.minecraftforge.common.IRarity;
|
|
||||||
|
|
||||||
public class ItemSwordAA extends SwordItem implements IDisableableItem {
|
public class ItemSwordAA extends SwordItem implements IDisableableItem {
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final IRarity rarity;
|
|
||||||
private final ItemStack repairItem;
|
|
||||||
private final boolean disabled;
|
private final boolean disabled;
|
||||||
|
|
||||||
public ItemSwordAA(IItemTier toolMat) {
|
public ItemSwordAA(IItemTier toolMat) {
|
||||||
super(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.");
|
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) {
|
if (!this.disabled) {
|
||||||
|
@ -42,21 +34,6 @@ public class ItemSwordAA extends SwordItem implements IDisableableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void 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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class<? extends ItemBlockBase> getItemBlock() {
|
protected Class<? extends ItemBlockBase> getItemBlock() {
|
||||||
|
@ -68,11 +45,6 @@ public class ItemSwordAA extends SwordItem implements IDisableableItem {
|
||||||
return ItemUtil.areItemsEqual(this.repairItem, stack, false);
|
return ItemUtil.areItemsEqual(this.repairItem, stack, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IRarity getForgeRarity(ItemStack stack) {
|
|
||||||
return this.rarity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDisabled() {
|
public boolean isDisabled() {
|
||||||
return this.disabled;
|
return this.disabled;
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.base;
|
package de.ellpeck.actuallyadditions.mod.items.base;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
|
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.config.ConfigurationHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
@ -27,7 +26,6 @@ import java.util.Set;
|
||||||
public class ItemToolAA extends ToolItem implements IDisableableItem {
|
public class ItemToolAA extends ToolItem implements IDisableableItem {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final IRarity rarity;
|
|
||||||
private final ItemStack repairItem;
|
private final ItemStack repairItem;
|
||||||
private String repairOredict;
|
private String repairOredict;
|
||||||
private final boolean disabled;
|
private final boolean disabled;
|
||||||
|
@ -50,26 +48,6 @@ public class ItemToolAA extends ToolItem implements IDisableableItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void 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 IRarity getForgeRarity(ItemStack stack) {
|
|
||||||
return this.rarity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,15 +16,16 @@ import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
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.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -56,25 +57,25 @@ public class LensColor extends Lens {
|
||||||
if (tile.getEnergy() >= ENERGY_USE) {
|
if (tile.getEnergy() >= ENERGY_USE) {
|
||||||
BlockState state = tile.getWorldObject().getBlockState(hitBlock);
|
BlockState state = tile.getWorldObject().getBlockState(hitBlock);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
int meta = block.getMetaFromState(state);
|
// int meta = block.getMetaFromState(state);
|
||||||
ItemStack returnStack = this.tryConvert(new ItemStack(block, 1, meta), hitState, hitBlock, tile);
|
ItemStack returnStack = this.tryConvert(new ItemStack(block), hitState, hitBlock, tile);
|
||||||
if (returnStack != null && returnStack.getItem() instanceof ItemBlock) {
|
if (returnStack != null && returnStack.getItem() instanceof BlockItem) {
|
||||||
Block toPlace = Block.getBlockFromItem(returnStack.getItem());
|
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.getWorldObject().setBlockState(hitBlock, state2Place, 2);
|
||||||
tile.extractEnergy(ENERGY_USE);
|
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));
|
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 (EntityItem item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (!item.isDead && StackUtil.isValid(item.getItem()) && tile.getEnergy() >= ENERGY_USE) {
|
if (item.isAlive() && StackUtil.isValid(item.getItem()) && tile.getEnergy() >= ENERGY_USE) {
|
||||||
ItemStack newStack = this.tryConvert(item.getItem(), hitState, hitBlock, tile);
|
ItemStack newStack = this.tryConvert(item.getItem(), hitState, hitBlock, tile);
|
||||||
if (StackUtil.isValid(newStack)) {
|
if (StackUtil.isValid(newStack)) {
|
||||||
item.setDead();
|
item.remove();
|
||||||
|
|
||||||
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
|
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), newStack);
|
||||||
tile.getWorldObject().spawnEntity(newItem);
|
tile.getWorldObject().addEntity(newItem);
|
||||||
|
|
||||||
tile.extractEnergy(ENERGY_USE);
|
tile.extractEnergy(ENERGY_USE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,19 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.DamageSources;
|
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.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
public class LensDeath extends Lens {
|
public class LensDeath extends Lens {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
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));
|
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 (EntityLivingBase entity : entities) {
|
for (LivingEntity entity : entities) {
|
||||||
int use = this.getUsePerEntity();
|
int use = this.getUsePerEntity();
|
||||||
if (tile.getEnergy() >= use) {
|
if (tile.getEnergy() >= use) {
|
||||||
tile.extractEnergy(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);
|
entity.attackEntityFrom(DamageSources.DAMAGE_ATOMIC_RECONSTRUCTOR, 20F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.Explosion;
|
||||||
|
|
||||||
public class LensDetonation extends Lens {
|
public class LensDetonation extends Lens {
|
||||||
|
|
||||||
|
@ -23,7 +25,7 @@ public class LensDetonation extends Lens {
|
||||||
public boolean invoke(BlockState state, BlockPos hitBlock, IAtomicReconstructor tile) {
|
public boolean invoke(BlockState state, BlockPos hitBlock, IAtomicReconstructor tile) {
|
||||||
if (hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)) {
|
if (hitBlock != null && !state.getBlock().isAir(state, tile.getWorldObject(), hitBlock)) {
|
||||||
if (tile.getEnergy() >= ENERGY_USE) {
|
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);
|
tile.extractEnergy(ENERGY_USE);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -14,14 +14,15 @@ import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.EnchantmentData;
|
import net.minecraft.enchantment.EnchantmentData;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.item.EnchantedBookItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemEnchantedBook;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -36,12 +37,12 @@ public class LensDisenchanting extends Lens {
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
||||||
if (tile.getEnergy() >= ENERGY_USE) {
|
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()) {
|
if (items != null && !items.isEmpty()) {
|
||||||
EntityItem book = null;
|
ItemEntity book = null;
|
||||||
EntityItem toDisenchant = null;
|
ItemEntity toDisenchant = null;
|
||||||
for (EntityItem item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item != null && !item.isDead) {
|
if (item != null && item.isAlive()) {
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (StackUtil.isValid(stack) && stack.getCount() == 1) {
|
if (StackUtil.isValid(stack) && stack.getCount() == 1) {
|
||||||
Item stackItem = stack.getItem();
|
Item stackItem = stack.getItem();
|
||||||
|
@ -70,7 +71,7 @@ public class LensDisenchanting extends Lens {
|
||||||
ItemStack bookStack = book.getItem();
|
ItemStack bookStack = book.getItem();
|
||||||
|
|
||||||
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(disenchantStack);
|
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(disenchantStack);
|
||||||
if (enchants != null && !enchants.isEmpty()) {
|
if (!enchants.isEmpty()) {
|
||||||
Enchantment enchant = enchants.keySet().iterator().next();
|
Enchantment enchant = enchants.keySet().iterator().next();
|
||||||
int level = enchants.get(enchant);
|
int level = enchants.get(enchant);
|
||||||
|
|
||||||
|
@ -83,14 +84,14 @@ public class LensDisenchanting extends Lens {
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemUtil.removeEnchantment(newDisenchantStack, enchant);
|
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);
|
ItemEntity disenchanted = new ItemEntity(toDisenchant.getEntityWorld(), toDisenchant.getPosX(), toDisenchant.getPosY(), toDisenchant.getPosZ(), newDisenchantStack);
|
||||||
EntityItem newBook = new EntityItem(book.getEntityWorld(), book.posX, book.posY, book.posZ, newBookStack);
|
ItemEntity newBook = new ItemEntity(book.getEntityWorld(), book.getPosX(), book.getPosY(), book.getPosZ(), newBookStack);
|
||||||
toDisenchant.setDead();
|
toDisenchant.remove();
|
||||||
book.setDead();
|
book.remove();
|
||||||
tile.getWorldObject().spawnEntity(newBook);
|
tile.getWorldObject().addEntity(newBook);
|
||||||
tile.getWorldObject().spawnEntity(disenchanted);
|
tile.getWorldObject().addEntity(disenchanted);
|
||||||
|
|
||||||
tile.extractEnergy(ENERGY_USE);
|
tile.extractEnergy(ENERGY_USE);
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ public class LensDisenchanting extends Lens {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] getColor() {
|
public float[] getColor() {
|
||||||
return new float[]{234F / 255F, 173F / 255F, 255F / 255F};
|
return new float[]{234F / 255F, 173F / 255F, 1.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,15 +16,18 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
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.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
public class LensDisruption extends Lens {
|
public class LensDisruption extends Lens {
|
||||||
|
|
||||||
|
@ -34,32 +37,28 @@ public class LensDisruption extends Lens {
|
||||||
public boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
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)) {
|
if (ConfigIntValues.ELEVEN.getValue() == 11 && tile.getEnergy() >= ENERGY_USE && hitBlock != null && !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock)) {
|
||||||
int range = 2;
|
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));
|
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 (EntityItem item : items) {
|
for (ItemEntity item : items) {
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (!item.isDead && StackUtil.isValid(stack)) {
|
if (item.isAlive() && StackUtil.isValid(stack)) {
|
||||||
if (!stack.hasTagCompound() || !stack.getTagCompound().getBoolean(ActuallyAdditions.MODID + "DisruptedAlready")) {
|
if (!stack.hasTag() || !stack.getOrCreateTag().getBoolean(ActuallyAdditions.MODID + "DisruptedAlready")) {
|
||||||
|
|
||||||
ItemStack newStack;
|
ItemStack newStack;
|
||||||
do {
|
do {
|
||||||
if (tile.getWorldObject().rand.nextBoolean()) {
|
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 {
|
} 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));
|
} while (!StackUtil.isValid(newStack));
|
||||||
|
|
||||||
newStack.setCount(stack.getCount());
|
newStack.setCount(stack.getCount());
|
||||||
|
newStack.getOrCreateTag().putBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true);
|
||||||
|
|
||||||
if (!newStack.hasTagCompound()) {
|
item.remove();
|
||||||
newStack.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
newStack.getTagCompound().putBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true);
|
|
||||||
|
|
||||||
item.setDead();
|
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), newStack);
|
||||||
|
tile.getWorldObject().addEntity(newItem);
|
||||||
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
|
|
||||||
tile.getWorldObject().spawnEntity(newItem);
|
|
||||||
|
|
||||||
tile.extractEnergy(ENERGY_USE);
|
tile.extractEnergy(ENERGY_USE);
|
||||||
}
|
}
|
||||||
|
@ -84,4 +83,12 @@ public class LensDisruption extends Lens {
|
||||||
public boolean canInvoke(IAtomicReconstructor tile, Direction sideToShootTo, int energyUsePerShot) {
|
public boolean canInvoke(IAtomicReconstructor tile, Direction sideToShootTo, int energyUsePerShot) {
|
||||||
return tile.getEnergy() - energyUsePerShot >= ENERGY_USE;
|
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())]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,17 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
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.util.DamageSource;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
|
||||||
public class LensKiller extends LensDeath {
|
public class LensKiller extends LensDeath {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAttacked(EntityLivingBase entity, IAtomicReconstructor tile) {
|
protected void onAttacked(LivingEntity entity, IAtomicReconstructor tile) {
|
||||||
if (!tile.getWorldObject().isRemote) {
|
if (!tile.getWorldObject().isRemote) {
|
||||||
entity.attackEntityFrom(DamageSource.causePlayerDamage(FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject())), 20);
|
entity.attackEntityFrom(DamageSource.causePlayerDamage(FakePlayerFactory.getMinecraft((ServerWorld) tile.getWorldObject())), 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,18 +21,15 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockNetherrack;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.BlockStone;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.block.NetherrackBlock;
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.WeightedRandom;
|
import net.minecraft.util.WeightedRandom;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -130,7 +127,7 @@ public class LensMining extends Lens {
|
||||||
Block hitBlock = hitState.getBlock();
|
Block hitBlock = hitState.getBlock();
|
||||||
if (hitBlock instanceof BlockStone) {
|
if (hitBlock instanceof BlockStone) {
|
||||||
ores = ActuallyAdditionsAPI.STONE_ORES;
|
ores = ActuallyAdditionsAPI.STONE_ORES;
|
||||||
} else if (hitBlock instanceof BlockNetherrack) {
|
} else if (hitBlock instanceof NetherrackBlock) {
|
||||||
ores = ActuallyAdditionsAPI.NETHERRACK_ORES;
|
ores = ActuallyAdditionsAPI.NETHERRACK_ORES;
|
||||||
adaptedUse += 10000;
|
adaptedUse += 10000;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,28 +10,24 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
|
||||||
import net.minecraft.util.IStringSerializable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
import net.minecraftforge.common.IRarity;
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public enum TheCrystals implements IStringSerializable {
|
public enum TheCrystals implements IStringSerializable {
|
||||||
|
|
||||||
REDSTONE("red", Util.CRYSTAL_RED_RARITY, 0xFF2F21, 158F / 255F, 43F / 255F, 39F / 255F),
|
REDSTONE("red", 0xFF2F21, 158F / 255F, 43F / 255F, 39F / 255F),
|
||||||
LAPIS("blue", Util.CRYSTAL_BLUE_RARITY, 0x5171FF, 37F / 255F, 49F / 255F, 147F / 255F),
|
LAPIS("blue", 0x5171FF, 37F / 255F, 49F / 255F, 147F / 255F),
|
||||||
DIAMOND("light_blue", Util.CRYSTAL_LIGHT_BLUE_RARITY, 0x35F1FF, 99F / 255F, 135F / 255F, 210F / 255F),
|
DIAMOND("light_blue", 0x35F1FF, 99F / 255F, 135F / 255F, 210F / 255F),
|
||||||
COAL("black", Util.CRYSTAL_BLACK_RARITY, 0x434442, 0.2F, 0.2F, 0.2F),
|
COAL("black", 0x434442, 0.2F, 0.2F, 0.2F),
|
||||||
EMERALD("green", Util.CRYSTAL_GREEN_RARITY, 0x44E033, 54F / 255F, 75F / 255F, 24F / 255F),
|
EMERALD("green", 0x44E033, 54F / 255F, 75F / 255F, 24F / 255F),
|
||||||
IRON("white", Util.CRYSTAL_WHITE_RARITY, 0xCEDDD4, 0.8F, 0.8F, 0.8F);
|
IRON("white", 0xCEDDD4, 0.8F, 0.8F, 0.8F);
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final IRarity rarity;
|
|
||||||
public final float[] conversionColorParticles;
|
public final float[] conversionColorParticles;
|
||||||
public final int clusterColor;
|
public final int clusterColor;
|
||||||
|
|
||||||
TheCrystals(String name, IRarity rarity, int clusterColor, float... conversionColorParticles) {
|
TheCrystals(String name, int clusterColor, float... conversionColorParticles) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.rarity = rarity;
|
|
||||||
this.conversionColorParticles = conversionColorParticles;
|
this.conversionColorParticles = conversionColorParticles;
|
||||||
this.clusterColor = clusterColor;
|
this.clusterColor = clusterColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,24 +11,25 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.Rarity;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public enum TheDusts {
|
public enum TheDusts {
|
||||||
|
|
||||||
IRON("iron", 7826534, EnumRarity.COMMON),
|
IRON("iron", 7826534, Rarity.COMMON),
|
||||||
GOLD("gold", 14335744, EnumRarity.UNCOMMON),
|
GOLD("gold", 14335744, Rarity.UNCOMMON),
|
||||||
DIAMOND("diamond", 292003, EnumRarity.RARE),
|
DIAMOND("diamond", 292003, Rarity.RARE),
|
||||||
EMERALD("emerald", 4319527, EnumRarity.EPIC),
|
EMERALD("emerald", 4319527, Rarity.EPIC),
|
||||||
LAPIS("lapis", 1849791, EnumRarity.UNCOMMON),
|
LAPIS("lapis", 1849791, Rarity.UNCOMMON),
|
||||||
QUARTZ("quartz", StringUtil.DECIMAL_COLOR_WHITE, EnumRarity.UNCOMMON),
|
QUARTZ("quartz", StringUtil.DECIMAL_COLOR_WHITE, Rarity.UNCOMMON),
|
||||||
COAL("coal", 0, EnumRarity.UNCOMMON),
|
COAL("coal", 0, Rarity.UNCOMMON),
|
||||||
QUARTZ_BLACK("quartz_black", 18, EnumRarity.RARE);
|
QUARTZ_BLACK("quartz_black", 18, Rarity.RARE);
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int color;
|
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.name = name;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.rarity = rarity;
|
this.rarity = rarity;
|
||||||
|
|
|
@ -12,43 +12,44 @@ package de.ellpeck.actuallyadditions.mod.items.metalists;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
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.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.item.Rarity;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public enum TheFoods {
|
public enum TheFoods {
|
||||||
|
|
||||||
CHEESE("cheese", 1, 0.05F, false, 3, EnumRarity.COMMON),
|
CHEESE("cheese", 1, 0.05F, false, 3, Rarity.COMMON),
|
||||||
PUMPKIN_STEW("pumpkin_stew", 6, 0.3F, true, 30, EnumRarity.COMMON),
|
PUMPKIN_STEW("pumpkin_stew", 6, 0.3F, true, 30, Rarity.COMMON),
|
||||||
CARROT_JUICE("carrot_juice", 4, 0.2F, true, 20, EnumRarity.COMMON),
|
CARROT_JUICE("carrot_juice", 4, 0.2F, true, 20, Rarity.COMMON),
|
||||||
FISH_N_CHIPS("fish_n_chips", 14, 0.65F, false, 40, EnumRarity.UNCOMMON),
|
FISH_N_CHIPS("fish_n_chips", 14, 0.65F, false, 40, Rarity.UNCOMMON),
|
||||||
FRENCH_FRIES("french_fries", 10, 0.6F, false, 32, EnumRarity.COMMON),
|
FRENCH_FRIES("french_fries", 10, 0.6F, false, 32, Rarity.COMMON),
|
||||||
FRENCH_FRY("french_fry", 2, 0.025F, false, 3, EnumRarity.COMMON),
|
FRENCH_FRY("french_fry", 2, 0.025F, false, 3, Rarity.COMMON),
|
||||||
SPAGHETTI("spaghetti", 7, 0.4F, false, 38, EnumRarity.COMMON),
|
SPAGHETTI("spaghetti", 7, 0.4F, false, 38, Rarity.COMMON),
|
||||||
NOODLE("noodle", 1, 0.01F, false, 3, EnumRarity.COMMON),
|
NOODLE("noodle", 1, 0.01F, false, 3, Rarity.COMMON),
|
||||||
CHOCOLATE_CAKE("chocolate_cake", 16, 0.8F, false, 45, EnumRarity.UNCOMMON),
|
CHOCOLATE_CAKE("chocolate_cake", 16, 0.8F, false, 45, Rarity.UNCOMMON),
|
||||||
CHOCOLATE("chocolate", 3, 0.3F, false, 15, EnumRarity.COMMON),
|
CHOCOLATE("chocolate", 3, 0.3F, false, 15, Rarity.COMMON),
|
||||||
TOAST("toast", 3, 0.08F, false, 25, EnumRarity.COMMON),
|
TOAST("toast", 3, 0.08F, false, 25, Rarity.COMMON),
|
||||||
SUBMARINE_SANDWICH("submarine_sandwich", 9, 0.4F, false, 40, EnumRarity.UNCOMMON),
|
SUBMARINE_SANDWICH("submarine_sandwich", 9, 0.4F, false, 40, Rarity.UNCOMMON),
|
||||||
BIG_COOKIE("big_cookie", 4, 0.25F, false, 20, EnumRarity.UNCOMMON),
|
BIG_COOKIE("big_cookie", 4, 0.25F, false, 20, Rarity.UNCOMMON),
|
||||||
HAMBURGER("hamburger", 13, 0.65F, false, 40, EnumRarity.COMMON),
|
HAMBURGER("hamburger", 13, 0.65F, false, 40, Rarity.COMMON),
|
||||||
PIZZA("pizza", 16, 0.8F, false, 45, EnumRarity.UNCOMMON),
|
PIZZA("pizza", 16, 0.8F, false, 45, Rarity.UNCOMMON),
|
||||||
BAGUETTE("baguette", 6, 0.5F, false, 25, EnumRarity.COMMON),
|
BAGUETTE("baguette", 6, 0.5F, false, 25, Rarity.COMMON),
|
||||||
RICE("rice", 2, 0.05F, false, 10, EnumRarity.UNCOMMON),
|
RICE("rice", 2, 0.05F, false, 10, Rarity.UNCOMMON),
|
||||||
RICE_BREAD("rice_bread", 6, 0.5F, false, 25, EnumRarity.UNCOMMON),
|
RICE_BREAD("rice_bread", 6, 0.5F, false, 25, Rarity.UNCOMMON),
|
||||||
DOUGHNUT("doughnut", 2, 0.1F, false, 10, EnumRarity.EPIC),
|
DOUGHNUT("doughnut", 2, 0.1F, false, 10, Rarity.EPIC),
|
||||||
CHOCOLATE_TOAST("chocolate_toast", 5, 0.2F, false, 40, EnumRarity.RARE),
|
CHOCOLATE_TOAST("chocolate_toast", 5, 0.2F, false, 40, Rarity.RARE),
|
||||||
BACON("bacon", 4, 0.1F, false, 30, EnumRarity.COMMON);
|
BACON("bacon", 4, 0.1F, false, 30, Rarity.COMMON);
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int healAmount;
|
public final int healAmount;
|
||||||
public final float saturation;
|
public final float saturation;
|
||||||
public final boolean getsDrunken;
|
public final boolean getsDrunken;
|
||||||
public final int useDuration;
|
public final int useDuration;
|
||||||
public final EnumRarity rarity;
|
public final Rarity rarity;
|
||||||
public ItemStack returnItem = StackUtil.getEmpty();
|
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.name = name;
|
||||||
this.getsDrunken = getsDrunken;
|
this.getsDrunken = getsDrunken;
|
||||||
this.healAmount = healAmount;
|
this.healAmount = healAmount;
|
||||||
|
@ -61,7 +62,7 @@ public enum TheFoods {
|
||||||
SPAGHETTI.returnItem = new ItemStack(Items.BOWL);
|
SPAGHETTI.returnItem = new ItemStack(Items.BOWL);
|
||||||
PUMPKIN_STEW.returnItem = new ItemStack(Items.BOWL);
|
PUMPKIN_STEW.returnItem = new ItemStack(Items.BOWL);
|
||||||
CARROT_JUICE.returnItem = new ItemStack(Items.GLASS_BOTTLE);
|
CARROT_JUICE.returnItem = new ItemStack(Items.GLASS_BOTTLE);
|
||||||
FRENCH_FRIES.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.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal());
|
FISH_N_CHIPS.returnItem = new ItemStack(InitItems.itemPaperCone.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,27 +10,28 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
||||||
|
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.Rarity;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public enum TheJams {
|
public enum TheJams {
|
||||||
|
|
||||||
CU_BA_RA("cu_ba_ra", 6, 0.1F, EnumRarity.RARE, 5, 12, 12595273),
|
CU_BA_RA("cu_ba_ra", 6, 0.1F, Rarity.RARE, 5, 12, 12595273),
|
||||||
GRA_KI_BA("gra_ki_ba", 6, 0.1F, EnumRarity.RARE, 16, 13, 5492820),
|
GRA_KI_BA("gra_ki_ba", 6, 0.1F, Rarity.RARE, 16, 13, 5492820),
|
||||||
PL_AP_LE("pl_ap_le", 6, 0.1F, EnumRarity.RARE, 15, 3, 13226009),
|
PL_AP_LE("pl_ap_le", 6, 0.1F, Rarity.RARE, 15, 3, 13226009),
|
||||||
CH_AP_CI("ch_ap_ci", 6, 0.1F, EnumRarity.RARE, 10, 1, 13189222),
|
CH_AP_CI("ch_ap_ci", 6, 0.1F, Rarity.RARE, 10, 1, 13189222),
|
||||||
HO_ME_KI("ho_me_ki", 6, 0.1F, EnumRarity.RARE, 10, 14, 2031360),
|
HO_ME_KI("ho_me_ki", 6, 0.1F, Rarity.RARE, 10, 14, 2031360),
|
||||||
PI_CO("pi_co", 6, 0.1F, EnumRarity.RARE, 9, 1, 16056203),
|
PI_CO("pi_co", 6, 0.1F, Rarity.RARE, 9, 1, 16056203),
|
||||||
HO_ME_CO("ho_me_co", 6, 0.1F, EnumRarity.RARE, 10, 13, 10462208);
|
HO_ME_CO("ho_me_co", 6, 0.1F, Rarity.RARE, 10, 13, 10462208);
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int healAmount;
|
public final int healAmount;
|
||||||
public final float saturation;
|
public final float saturation;
|
||||||
public final EnumRarity rarity;
|
public final Rarity rarity;
|
||||||
public final int firstEffectToGet;
|
public final int firstEffectToGet;
|
||||||
public final int secondEffectToGet;
|
public final int secondEffectToGet;
|
||||||
public final int color;
|
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.name = name;
|
||||||
this.healAmount = healAmount;
|
this.healAmount = healAmount;
|
||||||
this.saturation = saturation;
|
this.saturation = saturation;
|
||||||
|
|
|
@ -10,121 +10,131 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
package de.ellpeck.actuallyadditions.mod.items.metalists;
|
||||||
|
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.init.MobEffects;
|
|
||||||
import net.minecraft.item.EnumRarity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.item.Rarity;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public enum ThePotionRings {
|
public enum ThePotionRings {
|
||||||
|
|
||||||
SPEED(
|
SPEED(
|
||||||
MobEffects.SPEED.getName(),
|
MobEffects.SPEED.getName(),
|
||||||
8171462,
|
8171462,
|
||||||
MobEffects.SPEED,
|
MobEffects.SPEED,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.UNCOMMON,
|
Rarity.UNCOMMON,
|
||||||
new ItemStack(Items.SUGAR)),
|
new ItemStack(Items.SUGAR)
|
||||||
|
),
|
||||||
//Slowness
|
//Slowness
|
||||||
HASTE(
|
HASTE(
|
||||||
MobEffects.HASTE.getName(),
|
MobEffects.HASTE.getName(),
|
||||||
14270531,
|
14270531,
|
||||||
MobEffects.HASTE,
|
MobEffects.HASTE,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.EPIC,
|
Rarity.EPIC,
|
||||||
new ItemStack(Items.REPEATER)),
|
new ItemStack(Items.REPEATER)
|
||||||
|
),
|
||||||
//Mining Fatigue
|
//Mining Fatigue
|
||||||
STRENGTH(
|
STRENGTH(
|
||||||
MobEffects.STRENGTH.getName(),
|
MobEffects.STRENGTH.getName(),
|
||||||
9643043,
|
9643043,
|
||||||
MobEffects.STRENGTH,
|
MobEffects.STRENGTH,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.RARE,
|
Rarity.RARE,
|
||||||
new ItemStack(Items.BLAZE_POWDER)),
|
new ItemStack(Items.BLAZE_POWDER)
|
||||||
|
),
|
||||||
//Health (Not Happening)
|
//Health (Not Happening)
|
||||||
//Damage
|
//Damage
|
||||||
JUMP_BOOST(
|
JUMP_BOOST(
|
||||||
MobEffects.JUMP_BOOST.getName(),
|
MobEffects.JUMP_BOOST.getName(),
|
||||||
7889559,
|
7889559,
|
||||||
MobEffects.JUMP_BOOST,
|
MobEffects.JUMP_BOOST,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.RARE,
|
Rarity.RARE,
|
||||||
new ItemStack(Blocks.PISTON)),
|
new ItemStack(Blocks.PISTON)
|
||||||
|
),
|
||||||
//Nausea
|
//Nausea
|
||||||
REGEN(
|
REGEN(
|
||||||
MobEffects.REGENERATION.getName(),
|
MobEffects.REGENERATION.getName(),
|
||||||
13458603,
|
13458603,
|
||||||
MobEffects.REGENERATION,
|
MobEffects.REGENERATION,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
50,
|
50,
|
||||||
true,
|
true,
|
||||||
EnumRarity.RARE,
|
Rarity.RARE,
|
||||||
new ItemStack(Items.GHAST_TEAR)),
|
new ItemStack(Items.GHAST_TEAR)
|
||||||
|
),
|
||||||
RESISTANCE(
|
RESISTANCE(
|
||||||
MobEffects.RESISTANCE.getName(),
|
MobEffects.RESISTANCE.getName(),
|
||||||
10044730,
|
10044730,
|
||||||
MobEffects.RESISTANCE,
|
MobEffects.RESISTANCE,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.EPIC,
|
Rarity.EPIC,
|
||||||
new ItemStack(Items.SLIME_BALL)),
|
new ItemStack(Items.SLIME_BALL)
|
||||||
|
),
|
||||||
FIRE_RESISTANCE(
|
FIRE_RESISTANCE(
|
||||||
MobEffects.FIRE_RESISTANCE.getName(),
|
MobEffects.FIRE_RESISTANCE.getName(),
|
||||||
14981690,
|
14981690,
|
||||||
MobEffects.FIRE_RESISTANCE,
|
MobEffects.FIRE_RESISTANCE,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.UNCOMMON,
|
Rarity.UNCOMMON,
|
||||||
new ItemStack(Items.MAGMA_CREAM)),
|
new ItemStack(Items.MAGMA_CREAM)
|
||||||
|
),
|
||||||
WATER_BREATHING(
|
WATER_BREATHING(
|
||||||
MobEffects.WATER_BREATHING.getName(),
|
MobEffects.WATER_BREATHING.getName(),
|
||||||
3035801,
|
3035801,
|
||||||
MobEffects.WATER_BREATHING,
|
MobEffects.WATER_BREATHING,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.RARE,
|
Rarity.RARE,
|
||||||
new ItemStack(Items.FISH, 1, 3)),
|
new ItemStack(Items.FISH, 1, 3)
|
||||||
|
),
|
||||||
INVISIBILITY(
|
INVISIBILITY(
|
||||||
MobEffects.INVISIBILITY.getName(),
|
MobEffects.INVISIBILITY.getName(),
|
||||||
8356754,
|
8356754,
|
||||||
MobEffects.INVISIBILITY,
|
MobEffects.INVISIBILITY,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
EnumRarity.EPIC,
|
Rarity.EPIC,
|
||||||
new ItemStack(Items.FERMENTED_SPIDER_EYE)),
|
new ItemStack(Items.FERMENTED_SPIDER_EYE)
|
||||||
|
),
|
||||||
//Blindness
|
//Blindness
|
||||||
NIGHT_VISION(
|
NIGHT_VISION(
|
||||||
MobEffects.NIGHT_VISION.getName(),
|
MobEffects.NIGHT_VISION.getName(),
|
||||||
2039713,
|
2039713,
|
||||||
MobEffects.NIGHT_VISION,
|
MobEffects.NIGHT_VISION,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
300,
|
300,
|
||||||
false,
|
false,
|
||||||
EnumRarity.RARE,
|
Rarity.RARE,
|
||||||
new ItemStack(Items.GOLDEN_CARROT));
|
new ItemStack(Items.GOLDEN_CARROT)
|
||||||
|
);
|
||||||
//Hunger
|
//Hunger
|
||||||
//Weakness
|
//Weakness
|
||||||
//Poison
|
//Poison
|
||||||
|
@ -134,7 +144,7 @@ public enum ThePotionRings {
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
public final int color;
|
public final int color;
|
||||||
public final EnumRarity rarity;
|
public final Rarity rarity;
|
||||||
public final int effectID;
|
public final int effectID;
|
||||||
public final int normalAmplifier;
|
public final int normalAmplifier;
|
||||||
public final int advancedAmplifier;
|
public final int advancedAmplifier;
|
||||||
|
@ -142,7 +152,7 @@ public enum ThePotionRings {
|
||||||
public final boolean needsWaitBeforeActivating;
|
public final boolean needsWaitBeforeActivating;
|
||||||
public final ItemStack craftingItem;
|
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.name = name;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.rarity = rarity;
|
this.rarity = rarity;
|
||||||
|
|
|
@ -10,22 +10,23 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc;
|
package de.ellpeck.actuallyadditions.mod.misc;
|
||||||
|
|
||||||
import net.minecraft.block.BlockDispenser;
|
import net.minecraft.dispenser.DefaultDispenseItemBehavior;
|
||||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
|
||||||
import net.minecraft.dispenser.IBlockSource;
|
import net.minecraft.dispenser.IBlockSource;
|
||||||
import net.minecraft.item.ItemDye;
|
import net.minecraft.item.BoneMealItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
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
|
@Override
|
||||||
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
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);
|
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);
|
source.getWorld().playEvent(2005, pos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,20 @@ import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.potion.EffectInstance;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.potion.PotionEffect;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -57,10 +57,10 @@ public class MethodHandler implements IMethodHandler {
|
||||||
public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient) {
|
public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient) {
|
||||||
boolean worked = false;
|
boolean worked = false;
|
||||||
if (ingredient != null) {
|
if (ingredient != null) {
|
||||||
PotionEffect[] effects = ingredient.getEffects();
|
EffectInstance[] effects = ingredient.getEffects();
|
||||||
if (effects != null && effects.length > 0) {
|
if (effects != null && effects.length > 0) {
|
||||||
for (PotionEffect effect : effects) {
|
for (EffectInstance effect : effects) {
|
||||||
PotionEffect effectHas = this.getSameEffectFromStack(stack, effect);
|
EffectInstance effectHas = this.getSameEffectFromStack(stack, effect);
|
||||||
if (effectHas != null) {
|
if (effectHas != null) {
|
||||||
if (effectHas.getAmplifier() < ingredient.getMaxAmplifier() - 1) {
|
if (effectHas.getAmplifier() < ingredient.getMaxAmplifier() - 1) {
|
||||||
this.addEffectProperties(stack, effect, false, true);
|
this.addEffectProperties(stack, effect, false, true);
|
||||||
|
@ -77,10 +77,10 @@ public class MethodHandler implements IMethodHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect) {
|
public EffectInstance getSameEffectFromStack(ItemStack stack, EffectInstance effect) {
|
||||||
PotionEffect[] effectsStack = this.getEffectsFromStack(stack);
|
EffectInstance[] effectsStack = this.getEffectsFromStack(stack);
|
||||||
if (effectsStack != null && effectsStack.length > 0) {
|
if (effectsStack != null && effectsStack.length > 0) {
|
||||||
for (PotionEffect effectStack : effectsStack) {
|
for (EffectInstance effectStack : effectsStack) {
|
||||||
if (effect.getPotion() == effectStack.getPotion()) {
|
if (effect.getPotion() == effectStack.getPotion()) {
|
||||||
return effectStack;
|
return effectStack;
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,12 @@ public class MethodHandler implements IMethodHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp) {
|
public void addEffectProperties(ItemStack stack, EffectInstance effect, boolean addDur, boolean addAmp) {
|
||||||
PotionEffect[] effects = this.getEffectsFromStack(stack);
|
EffectInstance[] effects = this.getEffectsFromStack(stack);
|
||||||
stack.setTagCompound(new CompoundNBT());
|
stack.setTag(new CompoundNBT());
|
||||||
for (int i = 0; i < effects.length; i++) {
|
for (int i = 0; i < effects.length; i++) {
|
||||||
if (effects[i].getPotion() == effect.getPotion()) {
|
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()
|
? effect.getDuration()
|
||||||
: 0), effects[i].getAmplifier() + (addAmp
|
: 0), effects[i].getAmplifier() + (addAmp
|
||||||
? effect.getAmplifier() > 0
|
? effect.getAmplifier() > 0
|
||||||
|
@ -108,40 +108,35 @@ public class MethodHandler implements IMethodHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addEffectToStack(ItemStack stack, PotionEffect effect) {
|
public void addEffectToStack(ItemStack stack, EffectInstance effect) {
|
||||||
CompoundNBT tag = stack.getTagCompound();
|
CompoundNBT tag = stack.getOrCreateTag();
|
||||||
if (tag == null) {
|
|
||||||
tag = new CompoundNBT();
|
|
||||||
}
|
|
||||||
|
|
||||||
int prevCounter = tag.getInteger("Counter");
|
int prevCounter = tag.putInt("Counter");
|
||||||
CompoundNBT compound = new CompoundNBT();
|
CompoundNBT compound = new CompoundNBT();
|
||||||
compound.putInt("ID", Potion.getIdFromPotion(effect.getPotion()));
|
compound.putInt("ID", Potion.getIdFromPotion(effect.getPotion()));
|
||||||
compound.putInt("Duration", effect.getDuration());
|
compound.putInt("Duration", effect.getDuration());
|
||||||
compound.putInt("Amplifier", effect.getAmplifier());
|
compound.putInt("Amplifier", effect.getAmplifier());
|
||||||
|
|
||||||
int counter = prevCounter + 1;
|
int counter = prevCounter + 1;
|
||||||
tag.setTag(counter + "", compound);
|
tag.put(counter + "", compound);
|
||||||
tag.setInteger("Counter", counter);
|
tag.putInt("Counter", counter);
|
||||||
|
|
||||||
stack.setTagCompound(tag);
|
stack.setTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PotionEffect[] getEffectsFromStack(ItemStack stack) {
|
public EffectInstance[] getEffectsFromStack(ItemStack stack) {
|
||||||
ArrayList<PotionEffect> effects = new ArrayList<>();
|
ArrayList<EffectInstance> effects = new ArrayList<>();
|
||||||
CompoundNBT tag = stack.getTagCompound();
|
CompoundNBT tag = stack.getOrCreateTag();
|
||||||
if (tag != null) {
|
int counter = tag.getInt("Counter");
|
||||||
int counter = tag.getInteger("Counter");
|
while (counter > 0) {
|
||||||
while (counter > 0) {
|
CompoundNBT compound = (CompoundNBT) tag.get(counter + "");
|
||||||
CompoundNBT compound = (CompoundNBT) tag.getTag(counter + "");
|
EffectInstance effect = new EffectInstance(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
|
||||||
PotionEffect effect = new PotionEffect(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier"));
|
effects.add(effect);
|
||||||
effects.add(effect);
|
counter--;
|
||||||
counter--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return effects.size() > 0
|
return effects.size() > 0
|
||||||
? effects.toArray(new PotionEffect[effects.size()])
|
? effects.toArray(new EffectInstance[effects.size()])
|
||||||
: null;
|
: 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);
|
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);
|
tile.getWorldObject().setBlockState(pos, state2Place, 2);
|
||||||
} else {
|
} else {
|
||||||
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy());
|
ItemEntity item = new ItemEntity(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy());
|
||||||
tile.getWorldObject().spawnEntity(item);
|
tile.getWorldObject().addEntity(item);
|
||||||
tile.getWorldObject().setBlockState(pos, Blocks.AIR.getDefaultState());
|
tile.getWorldObject().setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,34 +199,34 @@ public class MethodHandler implements IMethodHandler {
|
||||||
|
|
||||||
//Converting the Items
|
//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);
|
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());
|
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);
|
List<ItemEntity> items = tile.getWorldObject().getEntitiesWithinAABB(ItemEntity.class, aabb);
|
||||||
for (EntityItem item : items) {
|
for (ItemEntity item : items) {
|
||||||
ItemStack stack = item.getItem();
|
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());
|
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens());
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount());
|
int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount());
|
||||||
|
|
||||||
if (itemsPossible > 0) {
|
if (itemsPossible > 0) {
|
||||||
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
|
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
|
||||||
item.setDead();
|
item.remove();
|
||||||
|
|
||||||
if (stack.getCount() - itemsPossible > 0) {
|
if (stack.getCount() - itemsPossible > 0) {
|
||||||
ItemStack stackCopy = stack.copy();
|
ItemStack stackCopy = stack.copy();
|
||||||
stackCopy.shrink(itemsPossible);
|
stackCopy.shrink(itemsPossible);
|
||||||
|
|
||||||
EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy);
|
ItemEntity inputLeft = new ItemEntity(tile.getWorldObject(), item.getPosX(), item.getPosY(), item.getPosZ(), stackCopy);
|
||||||
tile.getWorldObject().spawnEntity(inputLeft);
|
tile.getWorldObject().addEntity(inputLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack outputCopy = recipe.getOutput().copy();
|
ItemStack outputCopy = recipe.getOutput().copy();
|
||||||
outputCopy.setCount(itemsPossible);
|
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);
|
newItem.getEntityData().putBoolean("aa_cnv", true);
|
||||||
tile.getWorldObject().spawnEntity(newItem);
|
tile.getWorldObject().addEntity(newItem);
|
||||||
|
|
||||||
tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible);
|
tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class CactusFarmerBehavior implements IFarmerBehavior {
|
||||||
if (item instanceof BlockItem) {
|
if (item instanceof BlockItem) {
|
||||||
Block block = Block.getBlockFromItem(item);
|
Block block = Block.getBlockFromItem(item);
|
||||||
if (block == Blocks.CACTUS) {
|
if (block == Blocks.CACTUS) {
|
||||||
if (block.canPlaceBlockAt(world, pos)) {
|
if (block.getDefaultState().isValidPosition(world, pos)) {
|
||||||
BlockState state = block.getDefaultState();
|
BlockState state = block.getDefaultState();
|
||||||
world.setBlockState(pos, state, 2);
|
world.setBlockState(pos, state, 2);
|
||||||
world.playEvent(2001, pos, Block.getStateId(state));
|
world.playEvent(2001, pos, Block.getStateId(state));
|
||||||
|
|
|
@ -14,24 +14,18 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.block.IGrowable;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
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.IPlantable;
|
||||||
|
import net.minecraftforge.common.Tags;
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -43,7 +37,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
||||||
if (toPlant != null) {
|
if (toPlant != null) {
|
||||||
BlockPos farmland = pos.down();
|
BlockPos farmland = pos.down();
|
||||||
Block farmlandBlock = world.getBlockState(farmland).getBlock();
|
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());
|
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
useHoeAt(world, farmland);
|
useHoeAt(world, farmland);
|
||||||
world.playSound(null, farmland, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
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) {
|
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);
|
world.setBlockState(pos, toPlant);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -84,15 +78,17 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
if (block instanceof BlockCrops) {
|
if (block instanceof CropsBlock) {
|
||||||
if (((BlockCrops) block).isMaxAge(state)) {
|
if (((CropsBlock) 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)) {
|
|
||||||
return this.doFarmerStuff(state, world, pos, farmer);
|
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;
|
return FarmerResult.FAIL;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +150,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item instanceof IPlantable) {
|
if (item instanceof IPlantable) {
|
||||||
return (IPlantable) item;
|
return (IPlantable) item;
|
||||||
} else if (item instanceof ItemBlock) {
|
} else if (item instanceof BlockItem) {
|
||||||
Block block = Block.getBlockFromItem(item);
|
Block block = Block.getBlockFromItem(item);
|
||||||
if (block instanceof IPlantable) {
|
if (block instanceof IPlantable) {
|
||||||
return (IPlantable) block;
|
return (IPlantable) block;
|
||||||
|
@ -172,20 +168,20 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
||||||
return hoe;
|
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();
|
ItemStack itemstack = getHoeStack();
|
||||||
|
|
||||||
if (!player.canPlayerEdit(pos.offset(Direction.UP), Direction.UP, itemstack)) {
|
if (!player.canPlayerEdit(pos.offset(Direction.UP), Direction.UP, itemstack)) {
|
||||||
return EnumActionResult.FAIL;
|
return ActionResultType.FAIL;
|
||||||
} else {
|
} else {
|
||||||
int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(itemstack, player, world, pos);
|
int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(itemstack, player, world, pos);
|
||||||
if (hook != 0) {
|
if (hook != 0) {
|
||||||
return hook > 0
|
return hook > 0
|
||||||
? EnumActionResult.SUCCESS
|
? ActionResultType.SUCCESS
|
||||||
: EnumActionResult.FAIL;
|
: ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState iblockstate = world.getBlockState(pos);
|
BlockState iblockstate = world.getBlockState(pos);
|
||||||
|
@ -194,23 +190,23 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
|
||||||
if (world.isAirBlock(pos.up())) {
|
if (world.isAirBlock(pos.up())) {
|
||||||
if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) {
|
if (block == Blocks.GRASS || block == Blocks.GRASS_PATH) {
|
||||||
world.setBlockState(pos, Blocks.FARMLAND.getDefaultState());
|
world.setBlockState(pos, Blocks.FARMLAND.getDefaultState());
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block == Blocks.DIRT) {
|
if (block == Blocks.DIRT) {
|
||||||
switch (iblockstate.getValue(BlockDirt.VARIANT)) {
|
switch (iblockstate.get(BlockDirt.VARIANT)) {
|
||||||
case DIRT:
|
case DIRT:
|
||||||
world.setBlockState(pos, Blocks.FARMLAND.getDefaultState());
|
world.setBlockState(pos, Blocks.FARMLAND.getDefaultState());
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
case COARSE_DIRT:
|
case COARSE_DIRT:
|
||||||
world.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
world.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnumActionResult.PASS;
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,11 @@ import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -55,7 +56,7 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior {
|
||||||
if (farmer.getEnergy() >= use) {
|
if (farmer.getEnergy() >= use) {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block == Blocks.PUMPKIN || block == Blocks.MELON_BLOCK) {
|
if (block == Blocks.PUMPKIN || block == Blocks.MELON) {
|
||||||
NonNullList<ItemStack> drops = NonNullList.create();
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
block.getDrops(drops, world, pos, state, 0);
|
block.getDrops(drops, world, pos, state, 0);
|
||||||
if (!drops.isEmpty()) {
|
if (!drops.isEmpty()) {
|
||||||
|
|
|
@ -14,10 +14,12 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockNetherWart;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.block.NetherWartBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
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.Direction;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -47,8 +49,8 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior {
|
||||||
int use = 500;
|
int use = 500;
|
||||||
if (farmer.getEnergy() >= use) {
|
if (farmer.getEnergy() >= use) {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
if (state.getBlock() instanceof BlockNetherWart) {
|
if (state.getBlock() instanceof NetherWartBlock) {
|
||||||
if (state.getValue(BlockNetherWart.AGE) >= 3) {
|
if (state.get(BlockStateProperties.AGE_0_3) >= 3) {
|
||||||
NonNullList<ItemStack> drops = NonNullList.create();
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
state.getBlock().getDrops(drops, world, pos, state, 0);
|
state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||||
if (!drops.isEmpty()) {
|
if (!drops.isEmpty()) {
|
||||||
|
|
|
@ -14,10 +14,11 @@ import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockReed;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.block.SugarCaneBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
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) {
|
public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) {
|
||||||
int use = 250;
|
int use = 250;
|
||||||
if (farmer.getEnergy() >= use) {
|
if (farmer.getEnergy() >= use) {
|
||||||
if (seed.getItem() == Items.REEDS) {
|
if (seed.getItem() == Items.SUGAR_CANE) {
|
||||||
if (Blocks.REEDS.canPlaceBlockAt(world, pos)) {
|
if (Blocks.SUGAR_CANE.getDefaultState().isValidPosition(world, pos)) {
|
||||||
world.setBlockState(pos, Blocks.REEDS.getDefaultState(), 2);
|
world.setBlockState(pos, Blocks.SUGAR_CANE.getDefaultState(), 2);
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(use);
|
||||||
return FarmerResult.SUCCESS;
|
return FarmerResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -45,14 +46,14 @@ public class ReedFarmerBehavior implements IFarmerBehavior {
|
||||||
int use = 250;
|
int use = 250;
|
||||||
if (farmer.getEnergy() >= use) {
|
if (farmer.getEnergy() >= use) {
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
if (state.getBlock() instanceof BlockReed) {
|
if (state.getBlock() instanceof SugarCaneBlock) {
|
||||||
FarmerResult result = FarmerResult.STOP_PROCESSING;
|
FarmerResult result = FarmerResult.STOP_PROCESSING;
|
||||||
|
|
||||||
for (int i = 2; i >= 1; --i) {
|
for (int i = 2; i >= 1; --i) {
|
||||||
if (farmer.getEnergy() >= use) {
|
if (farmer.getEnergy() >= use) {
|
||||||
BlockPos up = pos.up(i);
|
BlockPos up = pos.up(i);
|
||||||
BlockState upState = world.getBlockState(up);
|
BlockState upState = world.getBlockState(up);
|
||||||
if (upState.getBlock() instanceof BlockReed) {
|
if (upState.getBlock() instanceof SugarCaneBlock) {
|
||||||
NonNullList<ItemStack> drops = NonNullList.create();
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
upState.getBlock().getDrops(drops, world, pos, state, 0);
|
upState.getBlock().getDrops(drops, world, pos, state, 0);
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,19 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc.special;
|
package de.ellpeck.actuallyadditions.mod.misc.special;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.client.Minecraft;
|
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.PlayerEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerModelPart;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.Util;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
|
||||||
public class RenderSpecial {
|
public class RenderSpecial {
|
||||||
|
|
||||||
|
@ -25,54 +32,54 @@ public class RenderSpecial {
|
||||||
this.theThingToRender = stack;
|
this.theThingToRender = stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(PlayerEntity player, float partialTicks) {
|
public void render(MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight, PlayerEntity player, float partialTicks) {
|
||||||
if (player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()) {
|
if (player.isInvisible() || !player.isWearing(PlayerModelPart.CAPE) || player.isElytraFlying()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
Vec3d currentPos = Minecraft.getInstance().player.getPositionEyes(partialTicks);
|
Vector3d currentPos = Minecraft.getInstance().player.getEyePosition(partialTicks);
|
||||||
Vec3d playerPos = player.getPositionEyes(partialTicks);
|
Vector3d playerPos = player.getEyePosition(partialTicks);
|
||||||
GlStateManager.translate(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z);
|
GlStateManager.translated(playerPos.x - currentPos.x, playerPos.y - currentPos.y, playerPos.z - currentPos.z);
|
||||||
GlStateManager.translate(0D, 2.575D - (player.isSneaking()
|
GlStateManager.translated(0D, 2.575D - (player.isSneaking()
|
||||||
? 0.125D
|
? 0.125D
|
||||||
: 0D), 0D);
|
: 0D), 0D);
|
||||||
|
|
||||||
this.render();
|
this.render(matrices, buffer, combinedLight);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render() {
|
public void render(MatrixStack matrices, IRenderTypeBuffer buffer, int combinedLight) {
|
||||||
if (StackUtil.isValid(this.theThingToRender)) {
|
if (StackUtil.isValid(this.theThingToRender)) {
|
||||||
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
|
boolean isBlock = this.theThingToRender.getItem() instanceof BlockItem;
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
if (isBlock) {
|
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
|
float size = isBlock
|
||||||
? 0.5F
|
? 0.5F
|
||||||
: 0.4F;
|
: 0.4F;
|
||||||
GlStateManager.scale(size, size, size);
|
GlStateManager.scalef(size, size, size);
|
||||||
|
|
||||||
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
|
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
|
||||||
//Peck edit: What do you mean by "nice" you jackass? >_>
|
//Peck edit: What do you mean by "nice" you jackass? >_>
|
||||||
double boop = Minecraft.getSystemTime() / 1000D;
|
double boop = Util.milliTime() / 1000D;
|
||||||
GlStateManager.translate(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D);
|
GlStateManager.translated(0D, Math.sin(boop % (2 * Math.PI)) * 0.25, 0D);
|
||||||
GlStateManager.rotate((float) (boop * 40D % 360), 0, 1, 0);
|
GlStateManager.rotatef((float) (boop * 40D % 360), 0, 1, 0);
|
||||||
|
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
if (!isBlock) {
|
if (!isBlock) {
|
||||||
GlStateManager.translate(0D, 0.5D, 0D);
|
GlStateManager.translated(0D, 0.5D, 0D);
|
||||||
}
|
}
|
||||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
GlStateManager.rotatef(180F, 1F, 0F, 0F);
|
||||||
AssetUtil.renderItemInWorld(this.theThingToRender, combinedLightIn, combinedOverlayIn, matrices, buffer);
|
AssetUtil.renderItemInWorld(this.theThingToRender, combinedLight, OverlayTexture.NO_OVERLAY, matrices, buffer);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
GlStateManager.enableLighting();
|
GlStateManager.enableLighting();
|
||||||
|
|
|
@ -16,8 +16,9 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -31,6 +32,7 @@ public class SpecialRenderInit {
|
||||||
new ThreadSpecialFetcher();
|
new ThreadSpecialFetcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: [port][note] ensure that this still works with the special people stuff
|
||||||
public static void parse(Properties properties) {
|
public static void parse(Properties properties) {
|
||||||
for (String key : properties.stringPropertyNames()) {
|
for (String key : properties.stringPropertyNames()) {
|
||||||
String[] values = properties.getProperty(key).split("@");
|
String[] values = properties.getProperty(key).split("@");
|
||||||
|
@ -45,7 +47,7 @@ public class SpecialRenderInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceLocation resLoc = new ResourceLocation(itemName);
|
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
|
//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)) {
|
if (!StackUtil.isValid(stack)) {
|
||||||
|
@ -58,7 +60,7 @@ public class SpecialRenderInit {
|
||||||
convertedItemName += c;
|
convertedItemName += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stack = findItem(new ResourceLocation(convertedItemName), meta);
|
stack = findItem(new ResourceLocation(convertedItemName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StackUtil.isValid(stack)) {
|
if (StackUtil.isValid(stack)) {
|
||||||
|
@ -68,16 +70,16 @@ public class SpecialRenderInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack findItem(ResourceLocation resLoc, int meta) {
|
private static ItemStack findItem(ResourceLocation resLoc) {
|
||||||
if (Item.REGISTRY.containsKey(resLoc)) {
|
if (ForgeRegistries.ITEMS.containsKey(resLoc)) {
|
||||||
Item item = Item.REGISTRY.getObject(resLoc);
|
Item item = ForgeRegistries.ITEMS.getValue(resLoc);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
return new ItemStack(item, 1, meta);
|
return new ItemStack(item);
|
||||||
}
|
}
|
||||||
} else if (Block.REGISTRY.containsKey(resLoc)) {
|
} else if (ForgeRegistries.BLOCKS.containsKey(resLoc)) {
|
||||||
Block block = Block.REGISTRY.getObject(resLoc);
|
Block block = ForgeRegistries.BLOCKS.getValue(resLoc);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
return new ItemStack(block, 1, meta);
|
return new ItemStack(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
|
@ -85,15 +87,13 @@ public class SpecialRenderInit {
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerRender(RenderPlayerEvent.Pre event) {
|
public void onPlayerRender(RenderPlayerEvent.Pre event) {
|
||||||
if (event.getEntityPlayer() != null) {
|
if (event.getPlayer() != null) {
|
||||||
String name = event.getEntityPlayer().getName();
|
String name = event.getPlayer().getName().getString();
|
||||||
if (name != null) {
|
String lower = name.toLowerCase(Locale.ROOT);
|
||||||
String lower = name.toLowerCase(Locale.ROOT);
|
if (SPECIAL_LIST.containsKey(lower)) {
|
||||||
if (SPECIAL_LIST.containsKey(lower)) {
|
RenderSpecial render = SPECIAL_LIST.get(lower);
|
||||||
RenderSpecial render = SPECIAL_LIST.get(lower);
|
if (render != null) {
|
||||||
if (render != null) {
|
render.render(event.getMatrixStack(), event.getBuffers(), event.getLight(), event.getPlayer(), event.getPartialRenderTick());
|
||||||
render.render(event.getEntityPlayer(), event.getPartialRenderTick());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.TheFoods;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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 final class InitOreDict {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
@ -32,49 +33,49 @@ public final class InitOreDict {
|
||||||
addOre(Items.COAL, "coal");
|
addOre(Items.COAL, "coal");
|
||||||
|
|
||||||
//Ores for Pulverizers etc.
|
//Ores for Pulverizers etc.
|
||||||
addOre(InitItems.itemDust, TheDusts.IRON.ordinal(), "dustIron");
|
addOre(InitItems.itemDust.get(), TheDusts.IRON.ordinal(), "dustIron");
|
||||||
addOre(InitItems.itemDust, TheDusts.GOLD.ordinal(), "dustGold");
|
addOre(InitItems.itemDust.get(), TheDusts.GOLD.ordinal(), "dustGold");
|
||||||
addOre(InitItems.itemDust, TheDusts.DIAMOND.ordinal(), "dustDiamond");
|
addOre(InitItems.itemDust.get(), TheDusts.DIAMOND.ordinal(), "dustDiamond");
|
||||||
addOre(InitItems.itemDust, TheDusts.EMERALD.ordinal(), "dustEmerald");
|
addOre(InitItems.itemDust.get(), TheDusts.EMERALD.ordinal(), "dustEmerald");
|
||||||
addOre(InitItems.itemDust, TheDusts.LAPIS.ordinal(), "dustLapis");
|
addOre(InitItems.itemDust.get(), TheDusts.LAPIS.ordinal(), "dustLapis");
|
||||||
addOre(InitItems.itemDust, TheDusts.QUARTZ.ordinal(), "dustQuartz");
|
addOre(InitItems.itemDust.get(), TheDusts.QUARTZ.ordinal(), "dustQuartz");
|
||||||
addOre(InitItems.itemDust, TheDusts.QUARTZ.ordinal(), "dustNetherQuartz");
|
addOre(InitItems.itemDust.get(), TheDusts.QUARTZ.ordinal(), "dustNetherQuartz");
|
||||||
addOre(InitItems.itemDust, TheDusts.COAL.ordinal(), "dustCoal");
|
addOre(InitItems.itemDust.get(), TheDusts.COAL.ordinal(), "dustCoal");
|
||||||
addOre(InitItems.itemDust, TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
|
addOre(InitItems.itemDust.get(), TheDusts.QUARTZ_BLACK.ordinal(), "dustQuartzBlack");
|
||||||
addOre(ActuallyBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
|
addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.ORE_QUARTZ.ordinal(), "oreQuartzBlack");
|
||||||
addOre(InitItems.itemMisc, TheMiscItems.QUARTZ.ordinal(), "gemQuartzBlack");
|
addOre(InitItems.itemMisc.get(), TheMiscItems.QUARTZ.ordinal(), "gemQuartzBlack");
|
||||||
|
|
||||||
//For Thermal Expansion Machine that "grows crops"
|
//For Thermal Expansion Machine that "grows crops"
|
||||||
addOre(InitItems.itemCanolaSeed, "seedCanola");
|
addOre(InitItems.itemCanolaSeed.get(), "seedCanola");
|
||||||
addOre(InitItems.itemMisc, TheMiscItems.CANOLA.ordinal(), "cropCanola");
|
addOre(InitItems.itemMisc.get(), TheMiscItems.CANOLA.ordinal(), "cropCanola");
|
||||||
addOre(InitItems.itemRiceSeed, "seedRice");
|
addOre(InitItems.itemRiceSeed.get(), "seedRice");
|
||||||
addOre(InitItems.itemFoods, TheFoods.RICE.ordinal(), "cropRice");
|
addOre(InitItems.itemFoods.get(), TheFoods.RICE.ordinal(), "cropRice");
|
||||||
addOre(InitItems.itemFlaxSeed, "seedFlax");
|
addOre(InitItems.itemFlaxSeed.get(), "seedFlax");
|
||||||
addOre(Items.STRING, "cropFlax");
|
addOre(Items.STRING, "cropFlax");
|
||||||
addOre(InitItems.itemCoffeeSeed, "seedCoffee");
|
addOre(InitItems.itemCoffeeSeed.get(), "seedCoffee");
|
||||||
addOre(InitItems.itemCoffeeBean, "cropCoffee");
|
addOre(InitItems.itemCoffeeBean.get(), "cropCoffee");
|
||||||
|
|
||||||
//For Crafting
|
//For Crafting
|
||||||
addOre(InitItems.itemMisc, TheMiscItems.RICE_SLIME.ordinal(), "slimeball");
|
addOre(InitItems.itemMisc.get(), TheMiscItems.RICE_SLIME.ordinal(), "slimeball");
|
||||||
addOre(ActuallyBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), "blockCharcoal");
|
addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), "blockCharcoal");
|
||||||
addOre(ActuallyBlocks.blockMisc, TheMiscBlocks.QUARTZ.ordinal(), "blockQuartzBlack");
|
addOre(ActuallyBlocks.blockMisc.get(), TheMiscBlocks.QUARTZ.ordinal(), "blockQuartzBlack");
|
||||||
addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack");
|
addOre(InitItems.itemMisc.get(), TheMiscItems.BLACK_DYE.ordinal(), "dyeBlack");
|
||||||
addOre(InitItems.itemMisc, TheMiscItems.BLACK_DYE.ordinal(), "dye");
|
addOre(InitItems.itemMisc.get(), TheMiscItems.BLACK_DYE.ordinal(), "dye");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addOre(Item item, int meta, String name) {
|
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) {
|
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) {
|
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) {
|
private static void addOre(ItemStack stack, String name) {
|
||||||
OreDictionary.registerOre(name, stack);
|
// OreDictionary.registerOre(name, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,19 +5,21 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.init.Items;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
// TODO: [port][test] check that this works
|
||||||
public class EnchBookConversion extends LensConversionRecipe {
|
public class EnchBookConversion extends LensConversionRecipe {
|
||||||
|
|
||||||
public EnchBookConversion() {
|
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
|
@Override
|
||||||
|
|
|
@ -1,56 +1,57 @@
|
||||||
/*
|
// 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
|
// * This file ("TreasureChestHandler.java") is part of the Actually Additions mod for Minecraft.
|
||||||
* under the Actually Additions License to be found at
|
// * It is created and owned by Ellpeck and distributed
|
||||||
* http://ellpeck.de/actaddlicense
|
// * under the Actually Additions License to be found at
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
// * http://ellpeck.de/actaddlicense
|
||||||
*
|
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
* © 2015-2017 Ellpeck
|
// *
|
||||||
*/
|
// * © 2015-2017 Ellpeck
|
||||||
|
// */
|
||||||
package de.ellpeck.actuallyadditions.mod.recipe;
|
//
|
||||||
|
//package de.ellpeck.actuallyadditions.mod.recipe;
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
//
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
|
//import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||||
import net.minecraft.init.Items;
|
//import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraft.init.Items;
|
||||||
|
//import net.minecraft.item.ItemStack;
|
||||||
public final class TreasureChestHandler {
|
//
|
||||||
|
//public final class TreasureChestHandler {
|
||||||
public static void init() {
|
//
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.DIAMOND), 5, 1, 2);
|
// public static void init() {
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.IRON_INGOT), 30, 1, 5);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.DIAMOND), 5, 1, 2);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_NUGGET), 60, 1, 8);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.IRON_INGOT), 30, 1, 5);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_INGOT), 35, 1, 3);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_NUGGET), 60, 1, 8);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.ENDER_PEARL), 10, 1, 2);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.GOLD_INGOT), 35, 1, 3);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EMERALD), 3, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.ENDER_PEARL), 10, 1, 2);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EXPERIENCE_BOTTLE), 5, 3, 6);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EMERALD), 3, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemSolidifiedExperience), 15, 3, 6);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.EXPERIENCE_BOTTLE), 5, 3, 6);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_11), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemSolidifiedExperience), 15, 3, 6);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_13), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_11), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_BLOCKS), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_13), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CAT), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_BLOCKS), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CHIRP), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CAT), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_FAR), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_CHIRP), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MALL), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_FAR), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MELLOHI), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MALL), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STAL), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_MELLOHI), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STRAD), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STAL), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WARD), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_STRAD), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WAIT), 1, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WARD), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.SADDLE), 5, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.RECORD_WAIT), 1, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.NAME_TAG), 20, 1, 2);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.SADDLE), 5, 1, 1);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.CU_BA_RA.ordinal()), 10, 1, 2);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.NAME_TAG), 20, 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.CU_BA_RA.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.GRA_KI_BA.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.PL_AP_LE.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.CH_AP_CI.ordinal()), 10, 1, 2);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), 10, 1, 2);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.HO_ME_KI.ordinal()), 10, 1, 2);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH), 80, 1, 3);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(InitItems.itemJams, 1, TheJams.PI_CO.ordinal()), 10, 1, 2);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 1), 60, 1, 3);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH), 80, 1, 3);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 2), 10, 1, 1);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 1), 60, 1, 3);
|
||||||
ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 3), 40, 1, 2);
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 2), 10, 1, 1);
|
||||||
}
|
// ActuallyAdditionsAPI.addTreasureChestLoot(new ItemStack(Items.FISH, 1, 3), 40, 1, 2);
|
||||||
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,89 +1,90 @@
|
||||||
/*
|
// 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
|
// * This file ("TileEntityGiantChest.java") is part of the Actually Additions mod for Minecraft.
|
||||||
* under the Actually Additions License to be found at
|
// * It is created and owned by Ellpeck and distributed
|
||||||
* http://ellpeck.de/actaddlicense
|
// * under the Actually Additions License to be found at
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
// * http://ellpeck.de/actaddlicense
|
||||||
*
|
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
* © 2015-2017 Ellpeck
|
// *
|
||||||
*/
|
// * © 2015-2017 Ellpeck
|
||||||
|
// */
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
//
|
||||||
|
//package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
//
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
//import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AwfulUtil;
|
//import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
//import de.ellpeck.actuallyadditions.mod.util.AwfulUtil;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
//import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
//import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.WorldServer;
|
//import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.storage.loot.ILootContainer;
|
//import net.minecraft.world.WorldServer;
|
||||||
import net.minecraft.world.storage.loot.LootContext;
|
//import net.minecraft.world.storage.loot.ILootContainer;
|
||||||
import net.minecraft.world.storage.loot.LootTable;
|
//import net.minecraft.world.storage.loot.LootContext;
|
||||||
|
//import net.minecraft.world.storage.loot.LootTable;
|
||||||
public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor, ILootContainer {
|
//
|
||||||
|
//public class TileEntityGiantChest extends TileEntityInventoryBase implements IButtonReactor, ILootContainer {
|
||||||
public ResourceLocation lootTable;
|
//
|
||||||
|
// public ResourceLocation lootTable;
|
||||||
public TileEntityGiantChest(int slotAmount, String name) {
|
//
|
||||||
super(slotAmount, name);
|
// public TileEntityGiantChest(int slotAmount, String name) {
|
||||||
}
|
// super(slotAmount, name);
|
||||||
|
// }
|
||||||
public TileEntityGiantChest() {
|
//
|
||||||
this(9 * 13, "giantChest");
|
// public TileEntityGiantChest() {
|
||||||
}
|
// this(9 * 13, "giantChest");
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
// @Override
|
||||||
super.writeSyncableNBT(compound, type);
|
// public void writeSyncableNBT(CompoundNBT compound, NBTType type) {
|
||||||
|
// super.writeSyncableNBT(compound, type);
|
||||||
if (this.lootTable != null) {
|
//
|
||||||
compound.setString("LootTable", this.lootTable.toString());
|
// if (this.lootTable != null) {
|
||||||
}
|
// compound.setString("LootTable", this.lootTable.toString());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
// @Override
|
||||||
super.readSyncableNBT(compound, type);
|
// public void readSyncableNBT(CompoundNBT compound, NBTType type) {
|
||||||
|
// super.readSyncableNBT(compound, type);
|
||||||
if (compound.hasKey("LootTable")) {
|
//
|
||||||
this.lootTable = new ResourceLocation(compound.getString("LootTable"));
|
// if (compound.hasKey("LootTable")) {
|
||||||
}
|
// this.lootTable = new ResourceLocation(compound.getString("LootTable"));
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public void onButtonPressed(int buttonID, PlayerEntity player) {
|
// @Override
|
||||||
if (player != null && this.pos != null) {
|
// public void onButtonPressed(int buttonID, PlayerEntity player) {
|
||||||
GuiHandler.GuiTypes type;
|
// if (player != null && this.pos != null) {
|
||||||
|
// GuiHandler.GuiTypes type;
|
||||||
if (buttonID == 0) {
|
//
|
||||||
type = GuiHandler.GuiTypes.GIANT_CHEST;
|
// if (buttonID == 0) {
|
||||||
} else if (buttonID == 1) {
|
// type = GuiHandler.GuiTypes.GIANT_CHEST;
|
||||||
type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2;
|
// } else if (buttonID == 1) {
|
||||||
} else {
|
// type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_2;
|
||||||
type = GuiHandler.GuiTypes.GIANT_CHEST_PAGE_3;
|
// } 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());
|
//
|
||||||
}
|
// player.openGui(ActuallyAdditions.INSTANCE, type.ordinal(), this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
@Override
|
//
|
||||||
public ResourceLocation getLootTable() {
|
// @Override
|
||||||
return this.lootTable;
|
// public ResourceLocation getLootTable() {
|
||||||
}
|
// return this.lootTable;
|
||||||
|
// }
|
||||||
public void fillWithLoot(PlayerEntity player) {
|
//
|
||||||
if (this.lootTable != null && !this.world.isRemote && this.world instanceof WorldServer) {
|
// public void fillWithLoot(PlayerEntity player) {
|
||||||
LootTable table = this.world.getLootTableManager().getLootTableFromLocation(this.lootTable);
|
// if (this.lootTable != null && !this.world.isRemote && this.world instanceof WorldServer) {
|
||||||
this.lootTable = null;
|
// LootTable table = this.world.getLootTableManager().getLootTableFromLocation(this.lootTable);
|
||||||
|
// this.lootTable = null;
|
||||||
LootContext.Builder builder = new LootContext.Builder((WorldServer) this.world);
|
//
|
||||||
if (player != null) {
|
// LootContext.Builder builder = new LootContext.Builder((WorldServer) this.world);
|
||||||
builder.withLuck(player.getLuck());
|
// if (player != null) {
|
||||||
}
|
// builder.withLuck(player.getLuck());
|
||||||
AwfulUtil.fillInventory(table, this.inv, this.world.rand, builder.build());
|
// }
|
||||||
}
|
// AwfulUtil.fillInventory(table, this.inv, this.world.rand, builder.build());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -17,10 +17,11 @@ import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
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.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.relauncher.OnlyIn;
|
|
||||||
|
|
||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
|
|
||||||
|
@ -46,11 +47,11 @@ public class UpdateChecker {
|
||||||
if (Minecraft.getInstance().player != null) {
|
if (Minecraft.getInstance().player != null) {
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
PlayerEntity player = Minecraft.getInstance().player;
|
||||||
if (UpdateChecker.checkFailed) {
|
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) {
|
} else if (UpdateChecker.needsUpdateNotify) {
|
||||||
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.generic")));
|
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localize("info." + ActuallyAdditions.MODID + ".update.generic")), false);
|
||||||
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString)));
|
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString)), false);
|
||||||
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)));
|
player.sendStatusMessage(ITextComponent.Serializer.getComponentFromJson(StringUtil.localizeFormatted("info." + ActuallyAdditions.MODID + ".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK)), false);
|
||||||
}
|
}
|
||||||
if (threadFinished) {
|
if (threadFinished) {
|
||||||
MinecraftForge.EVENT_BUS.unregister(this);
|
MinecraftForge.EVENT_BUS.unregister(this);
|
||||||
|
|
|
@ -1,107 +1,109 @@
|
||||||
/*
|
// 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
|
// * This file ("AwfulUtil.java") is part of the Actually Additions mod for Minecraft.
|
||||||
* under the Actually Additions License to be found at
|
// * It is created and owned by Ellpeck and distributed
|
||||||
* http://ellpeck.de/actaddlicense
|
// * under the Actually Additions License to be found at
|
||||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
// * http://ellpeck.de/actaddlicense
|
||||||
*
|
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
* © 2015-2017 Ellpeck
|
// *
|
||||||
*/
|
// * © 2015-2017 Ellpeck
|
||||||
|
// */
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
//
|
||||||
|
//package de.ellpeck.actuallyadditions.mod.util;
|
||||||
import java.util.Collections;
|
//
|
||||||
import java.util.Iterator;
|
//import com.google.common.collect.Lists;
|
||||||
import java.util.List;
|
//import net.minecraft.item.ItemStack;
|
||||||
import java.util.Random;
|
//import net.minecraft.loot.LootContext;
|
||||||
|
//import net.minecraft.loot.LootTable;
|
||||||
import com.google.common.collect.Lists;
|
//import net.minecraft.util.math.MathHelper;
|
||||||
|
//import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraft.item.ItemStack;
|
//import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraft.util.math.MathHelper;
|
//
|
||||||
import net.minecraft.world.storage.loot.LootContext;
|
//import java.util.Collections;
|
||||||
import net.minecraft.world.storage.loot.LootTable;
|
//import java.util.Iterator;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
//import java.util.List;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
//import java.util.Random;
|
||||||
|
//
|
||||||
//This is stuff copied from somewhere in vanilla and changed so that it works properly
|
////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
|
////It's unpolished and vanilla-y, so don't look at it! O_O
|
||||||
public final class AwfulUtil {
|
//public final class AwfulUtil {
|
||||||
|
//
|
||||||
public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context) {
|
// public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context) {
|
||||||
List<ItemStack> list = table.generateLootForPools(rand, context);
|
// List<ItemStack> list = table.generateLootForPools(rand, context);
|
||||||
List<Integer> list1 = getEmptySlotsRandomized(inventory, rand);
|
// List<Integer> list1 = getEmptySlotsRandomized(inventory, rand);
|
||||||
shuffleItems(list, list1.size(), rand);
|
// shuffleItems(list, list1.size(), rand);
|
||||||
|
//
|
||||||
for (ItemStack itemstack : list) {
|
// for (ItemStack itemstack : list) {
|
||||||
if (itemstack.isEmpty()) {
|
// if (itemstack.isEmpty()) {
|
||||||
inventory.setStackInSlot(list1.remove(list1.size() - 1), ItemStack.EMPTY);
|
// inventory.setStackInSlot(list1.remove(list1.size() - 1), ItemStack.EMPTY);
|
||||||
} else {
|
// } else {
|
||||||
inventory.setStackInSlot(list1.remove(list1.size() - 1), itemstack);
|
// inventory.setStackInSlot(list1.remove(list1.size() - 1), itemstack);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static void shuffleItems(List<ItemStack> stacks, int someInt, Random rand) {
|
// private static void shuffleItems(List<ItemStack> stacks, int someInt, Random rand) {
|
||||||
List<ItemStack> list = Lists.newArrayList();
|
// List<ItemStack> list = Lists.newArrayList();
|
||||||
Iterator<ItemStack> iterator = stacks.iterator();
|
// Iterator<ItemStack> iterator = stacks.iterator();
|
||||||
|
//
|
||||||
while (iterator.hasNext()) {
|
// while (iterator.hasNext()) {
|
||||||
ItemStack itemstack = iterator.next();
|
// ItemStack itemstack = iterator.next();
|
||||||
|
//
|
||||||
if (itemstack.isEmpty()) {
|
// if (itemstack.isEmpty()) {
|
||||||
iterator.remove();
|
// iterator.remove();
|
||||||
} else if (itemstack.getCount() > 1) {
|
// } else if (itemstack.getCount() > 1) {
|
||||||
list.add(itemstack);
|
// list.add(itemstack);
|
||||||
iterator.remove();
|
// iterator.remove();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
someInt = someInt - stacks.size();
|
// someInt = someInt - stacks.size();
|
||||||
|
//
|
||||||
while (someInt > 0 && list.size() > 0) {
|
// while (someInt > 0 && list.size() > 0) {
|
||||||
ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
|
// ItemStack itemstack2 = list.remove(MathHelper.nextInt(rand, 0, list.size() - 1));
|
||||||
int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2);
|
// int i = MathHelper.nextInt(rand, 1, itemstack2.getCount() / 2);
|
||||||
ItemStack itemstack1 = itemstack2.splitStack(i);
|
// ItemStack itemstack1 = itemstack2.split(i);
|
||||||
|
//
|
||||||
if (itemstack2.getCount() > 1 && rand.nextBoolean()) {
|
// if (itemstack2.getCount() > 1 && rand.nextBoolean()) {
|
||||||
list.add(itemstack2);
|
// list.add(itemstack2);
|
||||||
} else {
|
// } else {
|
||||||
stacks.add(itemstack2);
|
// stacks.add(itemstack2);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (itemstack1.getCount() > 1 && rand.nextBoolean()) {
|
// if (itemstack1.getCount() > 1 && rand.nextBoolean()) {
|
||||||
list.add(itemstack1);
|
// list.add(itemstack1);
|
||||||
} else {
|
// } else {
|
||||||
stacks.add(itemstack1);
|
// stacks.add(itemstack1);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
stacks.addAll(list);
|
// stacks.addAll(list);
|
||||||
Collections.shuffle(stacks, rand);
|
// Collections.shuffle(stacks, rand);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static List<Integer> getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand) {
|
// private static List<Integer> getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand) {
|
||||||
List<Integer> list = Lists.newArrayList();
|
// List<Integer> list = Lists.newArrayList();
|
||||||
|
//
|
||||||
for (int i = 0; i < inventory.getSlots(); ++i) {
|
// for (int i = 0; i < inventory.getSlots(); ++i) {
|
||||||
if (inventory.getStackInSlot(i).isEmpty()) {
|
// if (inventory.getStackInSlot(i).isEmpty()) {
|
||||||
list.add(i);
|
// list.add(i);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Collections.shuffle(list, rand);
|
// Collections.shuffle(list, rand);
|
||||||
return list;
|
// return list;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static void callTheFuckinPolice(Object... stuff) {
|
// public static void callTheFuckinPolice(Object... stuff) {
|
||||||
int i = 0;
|
// int i = 0;
|
||||||
String error = "Actually Additions: Something is very wrong. This method was provided with ";
|
// String error = "Actually Additions: Something is very wrong. This method was provided with ";
|
||||||
for (Object k : stuff) {
|
// for (Object k : stuff) {
|
||||||
error += "\n" + i++ + ": " + (k == null ? "null" : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ");
|
// error += "\n" + i++ + ": " + (k == null
|
||||||
}
|
// ? "null"
|
||||||
error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide();
|
// : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ");
|
||||||
error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
|
// }
|
||||||
throw new IllegalStateException(error);
|
// error += "\n" + "The current side is: " + FMLLoader.getDist().name();
|
||||||
}
|
// error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
|
||||||
}
|
// throw new IllegalStateException(error);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -10,24 +10,16 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
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.Enchantment;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.nbt.ListNBT;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Map;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public final class ItemUtil {
|
public final class ItemUtil {
|
||||||
|
|
||||||
|
@ -35,105 +27,51 @@ public final class ItemUtil {
|
||||||
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
|
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerBlock(Block block, ItemBlockBase itemBlock, String name, boolean addTab) {
|
// public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
|
||||||
block.setTranslationKey(ActuallyAdditions.MODID + "." + name);
|
// return getPlaceAt(array, stack, checkWildcard) != -1;
|
||||||
|
// }
|
||||||
block.setRegistryName(ActuallyAdditions.MODID, name);
|
//
|
||||||
RegistryHandler.BLOCKS_TO_REGISTER.add(block);
|
// public static int getPlaceAt(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
|
||||||
|
// return getPlaceAt(Arrays.asList(array), stack, checkWildcard);
|
||||||
itemBlock.setRegistryName(block.getRegistryName());
|
// }
|
||||||
RegistryHandler.ITEMS_TO_REGISTER.add(itemBlock);
|
//
|
||||||
|
// public static int getPlaceAt(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
|
||||||
block.setCreativeTab(addTab
|
// if (list != null && list.size() > 0) {
|
||||||
? CreativeTab.INSTANCE
|
// for (int i = 0; i < list.size(); i++) {
|
||||||
: null);
|
// if (!StackUtil.isValid(stack) && !StackUtil.isValid(list.get(i)) || areItemsEqual(stack, list.get(i), checkWildcard)) {
|
||||||
|
// return i;
|
||||||
IMCHandler.doBlockIMC(block);
|
// }
|
||||||
|
// }
|
||||||
if (block instanceof IColorProvidingBlock) {
|
// }
|
||||||
ActuallyAdditions.PROXY.addColoredBlock(block);
|
// return -1;
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard) {
|
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
|
// * Returns true if list contains stack or if both contain null
|
||||||
*/
|
// */
|
||||||
public static boolean contains(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
|
// public static boolean contains(List<ItemStack> list, ItemStack stack, boolean checkWildcard) {
|
||||||
return !(list == null || list.isEmpty()) && getPlaceAt(list, stack, checkWildcard) != -1;
|
// return !(list == null || list.isEmpty()) && getPlaceAt(list, stack, checkWildcard) != -1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static void addEnchantment(ItemStack stack, Enchantment e, int level) {
|
public static void addEnchantment(ItemStack stack, Enchantment e, int level) {
|
||||||
if (!hasEnchantment(stack, e)) {
|
if (!EnchantmentHelper.getEnchantments(stack).containsKey(e)) {
|
||||||
stack.addEnchantment(e, level);
|
stack.addEnchantment(e, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasEnchantment(ItemStack stack, Enchantment e) {
|
// TODO: [port] ensure this still works :D
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeEnchantment(ItemStack stack, Enchantment e) {
|
public static void removeEnchantment(ItemStack stack, Enchantment e) {
|
||||||
ListNBT ench = stack.getEnchantmentTagList();
|
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
|
||||||
if (ench != null) {
|
enchantments.remove(e);
|
||||||
for (int i = 0; i < ench.size(); i++) {
|
|
||||||
short id = ench.getCompound(i).getShort("id");
|
EnchantmentHelper.setEnchantments(enchantments, stack);
|
||||||
if (id == Enchantment.getEnchantmentID(e)) {
|
|
||||||
ench.removeTag(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ench.isEmpty() && stack.hasTagCompound()) {
|
|
||||||
stack.getTagCompound().removeTag("ench");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) {
|
public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) {
|
||||||
|
@ -141,7 +79,7 @@ public final class ItemUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEnabled(ItemStack stack) {
|
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) {
|
public static void changeEnabled(PlayerEntity player, Hand hand) {
|
||||||
|
@ -149,11 +87,7 @@ public final class ItemUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void changeEnabled(ItemStack stack) {
|
public static void changeEnabled(ItemStack stack) {
|
||||||
if (!stack.hasTagCompound()) {
|
|
||||||
stack.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isEnabled = isEnabled(stack);
|
boolean isEnabled = isEnabled(stack);
|
||||||
stack.getTagCompound().putBoolean("IsEnabled", !isEnabled);
|
stack.getOrCreateTag().putBoolean("IsEnabled", !isEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +1,17 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
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.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.StringJoiner;
|
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 class RefHelp {
|
||||||
|
|
||||||
public static class UnableToFindMethodException extends RuntimeException {
|
public static class UnableToFindMethodException extends RuntimeException {
|
||||||
|
@ -62,7 +59,7 @@ public class RefHelp {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class UnknownConstructorException extends RuntimeException {
|
public static class UnknownConstructorException extends RuntimeException {
|
||||||
public UnknownConstructorException(final String message) {
|
public UnknownConstructorException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +83,9 @@ public class RefHelp {
|
||||||
Preconditions.checkNotNull(clazz);
|
Preconditions.checkNotNull(clazz);
|
||||||
Preconditions.checkArgument(StringUtils.isNotEmpty(fieldName), "Field name cannot be empty");
|
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 {
|
try {
|
||||||
Field f = clazz.getDeclaredField(nameToFind);
|
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").
|
* @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.
|
* 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.
|
* @param parameterTypes The parameter types of the method to find.
|
||||||
|
*
|
||||||
* @return The method with the specified name and parameters in the given class.
|
* @return The method with the specified name and parameters in the given class.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -184,7 +184,10 @@ public class RefHelp {
|
||||||
Preconditions.checkNotNull(clazz);
|
Preconditions.checkNotNull(clazz);
|
||||||
Preconditions.checkArgument(StringUtils.isNotEmpty(methodName), "Method name cannot be empty");
|
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 {
|
try {
|
||||||
Method m = clazz.getDeclaredMethod(nameToFind, parameterTypes);
|
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.
|
* 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 parameterTypes The parameter types of the constructor.
|
||||||
* @param <T> The type
|
* @param <T> The type
|
||||||
|
*
|
||||||
* @return The constructor
|
* @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
|
* @throws UnknownConstructorException if the constructor could not be found
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@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(klass, "class");
|
||||||
Preconditions.checkNotNull(parameterTypes, "parameter types");
|
Preconditions.checkNotNull(parameterTypes, "parameter types");
|
||||||
|
|
||||||
|
@ -215,8 +220,8 @@ public class RefHelp {
|
||||||
Constructor<T> constructor = klass.getDeclaredConstructor(parameterTypes);
|
Constructor<T> constructor = klass.getDeclaredConstructor(parameterTypes);
|
||||||
constructor.setAccessible(true);
|
constructor.setAccessible(true);
|
||||||
return constructor;
|
return constructor;
|
||||||
} catch (final NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
final StringBuilder desc = new StringBuilder();
|
StringBuilder desc = new StringBuilder();
|
||||||
desc.append(klass.getSimpleName());
|
desc.append(klass.getSimpleName());
|
||||||
|
|
||||||
StringJoiner joiner = new StringJoiner(", ", "(", ")");
|
StringJoiner joiner = new StringJoiner(", ", "(", ")");
|
||||||
|
|
|
@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapp
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
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.
|
* @return If the stack is not empty, or if it's an IDisableableItem, if its enabled.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean isValid(ItemStack stack) {
|
public static boolean isValid(ItemStack stack) {
|
||||||
return stack != null && !stack.isEmpty();
|
return stack != null && !stack.isEmpty();
|
||||||
// if (stack == null) AwfulUtil.callTheFuckinPolice("Null ItemStack detected", stack);
|
// if (stack == null) AwfulUtil.callTheFuckinPolice("Null ItemStack detected", stack);
|
||||||
|
@ -40,21 +40,11 @@ public final class StackUtil {
|
||||||
/**
|
/**
|
||||||
* @return The empty itemstack instance.
|
* @return The empty itemstack instance.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static ItemStack getEmpty() {
|
public static ItemStack getEmpty() {
|
||||||
return ItemStack.EMPTY;
|
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.
|
* 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()}
|
* @return If all stacks in the collection return true for {@link ItemStack#isEmpty()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean isEmpty(Collection<ItemStack> stacks) {
|
public static boolean isEmpty(Collection<ItemStack> stacks) {
|
||||||
if (stacks.isEmpty()) {
|
if (stacks.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -230,12 +221,12 @@ public final class StackUtil {
|
||||||
|
|
||||||
if (ActuallyAdditions.commonCapsLoaded) {
|
if (ActuallyAdditions.commonCapsLoaded) {
|
||||||
Object handler = wrapper.getSlotlessHandler();
|
Object handler = wrapper.getSlotlessHandler();
|
||||||
if (handler instanceof ISlotlessItemHandler) {
|
// if (handler instanceof ISlotlessItemHandler) {
|
||||||
remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
|
// remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
|
||||||
if (!ItemStack.areItemStacksEqual(remain, stack)) {
|
// if (!ItemStack.areItemStacksEqual(remain, stack)) {
|
||||||
return remain;
|
// return remain;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
IItemHandler handler = wrapper.getNormalHandler();
|
IItemHandler handler = wrapper.getNormalHandler();
|
||||||
|
|
|
@ -10,18 +10,18 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
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.io.InputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
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 final class StringUtil {
|
||||||
|
|
||||||
public static final int DECIMAL_COLOR_WHITE = 16777215;
|
public static final int DECIMAL_COLOR_WHITE = 16777215;
|
||||||
|
@ -45,7 +45,8 @@ public final class StringUtil {
|
||||||
return I18n.format(text, replace);
|
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) {
|
public static String localizeIllegallyOnTheServerDontUseMePls(String langKey) {
|
||||||
return net.minecraft.util.text.translation.I18n.translateToLocal(langKey);
|
return net.minecraft.util.text.translation.I18n.translateToLocal(langKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,36 +11,22 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraftforge.fml.loading.FMLLoader;
|
||||||
import net.minecraftforge.common.IRarity;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
public final class Util {
|
public final class Util {
|
||||||
|
|
||||||
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
|
@Deprecated
|
||||||
public static final int BUCKET = Fluid.BUCKET_VOLUME;
|
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");
|
@Deprecated
|
||||||
public static final IRarity CRYSTAL_BLUE_RARITY = addRarity("crystalBlue", TextFormatting.DARK_BLUE, ActuallyAdditions.NAME + " Blue Crystal");
|
public static final int BUCKET = 1000;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isDevVersion() {
|
public static boolean isDevVersion() {
|
||||||
return ActuallyAdditions.VERSION.equals("@VERSION@");
|
return ActuallyAdditions.VERSION.equals("@VERSION@");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClient() {
|
public static boolean isClient() {
|
||||||
return FMLCommonHandler.instance().getEffectiveSide().isClient();
|
return FMLLoader.getDist().isClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] splitVersion() {
|
private static String[] splitVersion() {
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
|
||||||
public final class VanillaPacketDispatcher {
|
public final class VanillaPacketDispatcher {
|
||||||
|
|
||||||
//Don't call from the client.
|
//Don't call from the client.
|
||||||
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
|
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);
|
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4);
|
||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
|
Loading…
Reference in a new issue