BloodMagic/src/main/java/WayofTime/bloodmagic/block/BlockTeleposer.java

70 lines
2.5 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.block;
2017-08-16 04:30:48 +00:00
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IVariantProvider;
Command rework (#1434) * Network part finished. * Should be more reasonable now * This should be good enough. * Orb finished, needs strings * Bind finished. Needs strings. * Reformat & Help subcommand * Cleanup, strings, no negative amounts * Removed TODOs * Added missing MaxTier check for Blood Orbs. Added TODO: Test with custom Blood Orbs. * Ritual commands finished. Check for valid placement might be optimized. (TODO) * Access modifiers, moved TODO * Added TODOs for localized strings * DrainUtils postponed until the necessary functionality is available with SoulTickets (telling SoulTicket network from soul ticket, a list of all registered soul tickets per network) * Replaced all occurrences of TextHelper with TextComponentTranslation in the commands section * - Moved Teleports.java to teleport package - added teleposer command - added missing strings - cleanup * Fixed spelling of "Successful(ly)" * getUsage() now returns translation keys. getInfo() is now an explicit String ritual creation command now has proper tab completions help is an additional argument with "-h" or "?" cleanup * teleposerSet final cleanup. * Removed ritual removal command Signed-off-by: tobias <angryaeon@icloud.com> * Check if the tile has a ritual first Signed-off-by: tobias <angryaeon@icloud.com> * A bit more optimisation Signed-off-by: tobias <angryaeon@icloud.com> * Cleanup part 1 Signed-off-by: tobias <angryaeon@icloud.com> * Cleanup part 2 Signed-off-by: tobias <angryaeon@icloud.com> * Part 3 Signed-off-by: tobias <angryaeon@icloud.com> * Part 4 Signed-off-by: tobias <angryaeon@icloud.com> * Updated language file to reflect cleanup & continuity changes. Signed-off-by: tobias <angryaeon@icloud.com> * Change to use an abstract class that gets called instead of calling super on overriden execute() for commands Signed-off-by: tobias <angryaeon@icloud.com> * Use player facing for ritual creation. Signed-off-by: tobias <angryaeon@icloud.com>
2019-02-01 00:46:02 +00:00
import WayofTime.bloodmagic.command.sub.SubCommandTeleposer;
2017-08-16 04:30:48 +00:00
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
import WayofTime.bloodmagic.tile.TileTeleposer;
2018-03-08 03:43:00 +00:00
import WayofTime.bloodmagic.util.Constants;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
2017-08-16 04:24:59 +00:00
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
2016-03-18 17:16:38 +00:00
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
2016-03-18 17:16:38 +00:00
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
2016-03-16 22:37:55 +00:00
2017-08-16 04:30:48 +00:00
public class BlockTeleposer extends BlockContainer implements IVariantProvider, IBMBlock {
public BlockTeleposer() {
2016-04-24 17:06:28 +00:00
super(Material.ROCK);
setCreativeTab(BloodMagic.TAB_BM);
2019-02-01 03:10:37 +00:00
setTranslationKey(BloodMagic.MODID + ".teleposer");
setHardness(2.0F);
setResistance(5.0F);
}
@Override
2017-08-16 04:30:48 +00:00
public EnumBlockRenderType getRenderType(IBlockState state) {
2016-03-18 17:16:38 +00:00
return EnumBlockRenderType.MODEL;
}
@Override
2017-08-16 04:30:48 +00:00
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
2017-01-02 05:43:34 +00:00
ItemStack playerItem = player.getHeldItem(hand);
2017-01-02 05:43:34 +00:00
if (playerItem.getItem() instanceof ItemTelepositionFocus)
((ItemTelepositionFocus) playerItem.getItem()).setBlockPos(playerItem, world, pos);
else if (world.getTileEntity(pos) instanceof TileTeleposer)
2016-01-01 17:08:17 +00:00
player.openGui(BloodMagic.instance, Constants.Gui.TELEPOSER_GUI, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
2016-01-01 17:08:17 +00:00
@Override
2017-08-16 04:30:48 +00:00
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
TileTeleposer tileTeleposer = (TileTeleposer) world.getTileEntity(blockPos);
Command rework (#1434) * Network part finished. * Should be more reasonable now * This should be good enough. * Orb finished, needs strings * Bind finished. Needs strings. * Reformat & Help subcommand * Cleanup, strings, no negative amounts * Removed TODOs * Added missing MaxTier check for Blood Orbs. Added TODO: Test with custom Blood Orbs. * Ritual commands finished. Check for valid placement might be optimized. (TODO) * Access modifiers, moved TODO * Added TODOs for localized strings * DrainUtils postponed until the necessary functionality is available with SoulTickets (telling SoulTicket network from soul ticket, a list of all registered soul tickets per network) * Replaced all occurrences of TextHelper with TextComponentTranslation in the commands section * - Moved Teleports.java to teleport package - added teleposer command - added missing strings - cleanup * Fixed spelling of "Successful(ly)" * getUsage() now returns translation keys. getInfo() is now an explicit String ritual creation command now has proper tab completions help is an additional argument with "-h" or "?" cleanup * teleposerSet final cleanup. * Removed ritual removal command Signed-off-by: tobias <angryaeon@icloud.com> * Check if the tile has a ritual first Signed-off-by: tobias <angryaeon@icloud.com> * A bit more optimisation Signed-off-by: tobias <angryaeon@icloud.com> * Cleanup part 1 Signed-off-by: tobias <angryaeon@icloud.com> * Cleanup part 2 Signed-off-by: tobias <angryaeon@icloud.com> * Part 3 Signed-off-by: tobias <angryaeon@icloud.com> * Part 4 Signed-off-by: tobias <angryaeon@icloud.com> * Updated language file to reflect cleanup & continuity changes. Signed-off-by: tobias <angryaeon@icloud.com> * Change to use an abstract class that gets called instead of calling super on overriden execute() for commands Signed-off-by: tobias <angryaeon@icloud.com> * Use player facing for ritual creation. Signed-off-by: tobias <angryaeon@icloud.com>
2019-02-01 00:46:02 +00:00
if (tileTeleposer != null) {
tileTeleposer.dropItems();
Command rework (#1434) * Network part finished. * Should be more reasonable now * This should be good enough. * Orb finished, needs strings * Bind finished. Needs strings. * Reformat & Help subcommand * Cleanup, strings, no negative amounts * Removed TODOs * Added missing MaxTier check for Blood Orbs. Added TODO: Test with custom Blood Orbs. * Ritual commands finished. Check for valid placement might be optimized. (TODO) * Access modifiers, moved TODO * Added TODOs for localized strings * DrainUtils postponed until the necessary functionality is available with SoulTickets (telling SoulTicket network from soul ticket, a list of all registered soul tickets per network) * Replaced all occurrences of TextHelper with TextComponentTranslation in the commands section * - Moved Teleports.java to teleport package - added teleposer command - added missing strings - cleanup * Fixed spelling of "Successful(ly)" * getUsage() now returns translation keys. getInfo() is now an explicit String ritual creation command now has proper tab completions help is an additional argument with "-h" or "?" cleanup * teleposerSet final cleanup. * Removed ritual removal command Signed-off-by: tobias <angryaeon@icloud.com> * Check if the tile has a ritual first Signed-off-by: tobias <angryaeon@icloud.com> * A bit more optimisation Signed-off-by: tobias <angryaeon@icloud.com> * Cleanup part 1 Signed-off-by: tobias <angryaeon@icloud.com> * Cleanup part 2 Signed-off-by: tobias <angryaeon@icloud.com> * Part 3 Signed-off-by: tobias <angryaeon@icloud.com> * Part 4 Signed-off-by: tobias <angryaeon@icloud.com> * Updated language file to reflect cleanup & continuity changes. Signed-off-by: tobias <angryaeon@icloud.com> * Change to use an abstract class that gets called instead of calling super on overriden execute() for commands Signed-off-by: tobias <angryaeon@icloud.com> * Use player facing for ritual creation. Signed-off-by: tobias <angryaeon@icloud.com>
2019-02-01 00:46:02 +00:00
SubCommandTeleposer.teleposerSet.remove(tileTeleposer);
}
2016-01-01 17:08:17 +00:00
super.breakBlock(world, blockPos, blockState);
2016-01-01 17:08:17 +00:00
}
@Override
2017-08-16 04:30:48 +00:00
public TileEntity createNewTileEntity(World worldIn, int meta) {
2016-01-01 17:08:17 +00:00
return new TileTeleposer();
}
2016-03-16 22:37:55 +00:00
2017-08-16 04:24:59 +00:00
@Override
public ItemBlock getItem() {
return new ItemBlock(this);
}
}