2016-06-05 04:05:37 +02:00
/ *
* This file ( " BlockPlayerInterface.java " ) is part of the Actually Additions mod for Minecraft .
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http : //ellpeck.de/actaddlicense
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
* © 2015 - 2016 Ellpeck
* /
package de.ellpeck.actuallyadditions.mod.blocks ;
2016-07-14 02:11:41 +02:00
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile ;
2016-06-05 04:05:37 +02:00
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase ;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface ;
2016-07-14 02:11:41 +02:00
import de.ellpeck.actuallyadditions.mod.util.ModUtil ;
import de.ellpeck.actuallyadditions.mod.util.StringUtil ;
import net.minecraft.block.Block ;
2016-06-05 04:05:37 +02:00
import net.minecraft.block.SoundType ;
import net.minecraft.block.material.Material ;
import net.minecraft.block.state.IBlockState ;
2016-07-14 02:11:41 +02:00
import net.minecraft.client.Minecraft ;
import net.minecraft.client.gui.ScaledResolution ;
2016-06-05 04:05:37 +02:00
import net.minecraft.entity.EntityLivingBase ;
2016-07-14 02:11:41 +02:00
import net.minecraft.entity.player.EntityPlayer ;
2016-06-05 04:05:37 +02:00
import net.minecraft.item.EnumRarity ;
2016-07-14 02:11:41 +02:00
import net.minecraft.item.Item ;
2016-06-05 04:05:37 +02:00
import net.minecraft.item.ItemStack ;
2016-07-14 02:11:41 +02:00
import net.minecraft.profiler.Profiler ;
2016-06-05 04:05:37 +02:00
import net.minecraft.tileentity.TileEntity ;
import net.minecraft.util.math.BlockPos ;
2016-07-14 02:11:41 +02:00
import net.minecraft.util.math.RayTraceResult ;
import net.minecraft.util.math.Vec3d ;
import net.minecraft.util.text.TextFormatting ;
2016-06-05 04:05:37 +02:00
import net.minecraft.world.World ;
2016-07-14 02:11:41 +02:00
import net.minecraftforge.fml.relauncher.Side ;
import net.minecraftforge.fml.relauncher.SideOnly ;
2016-06-05 04:05:37 +02:00
2016-07-14 02:11:41 +02:00
public class BlockPlayerInterface extends BlockContainerBase implements IHudDisplay {
2016-06-05 04:05:37 +02:00
public BlockPlayerInterface ( String name ) {
super ( Material . ROCK , name ) ;
this . setHarvestLevel ( " pickaxe " , 0 ) ;
this . setHardness ( 4 . 5F ) ;
this . setResistance ( 10 . 0F ) ;
this . setSoundType ( SoundType . STONE ) ;
}
@Override
public TileEntity createNewTileEntity ( World world , int par2 ) {
return new TileEntityPlayerInterface ( ) ;
}
@Override
public EnumRarity getRarity ( ItemStack stack ) {
return EnumRarity . EPIC ;
}
@Override
public void onBlockPlacedBy ( World world , BlockPos pos , IBlockState state , EntityLivingBase player , ItemStack stack ) {
TileEntity tile = world . getTileEntity ( pos ) ;
if ( tile ! = null & & tile instanceof TileEntityPlayerInterface ) {
TileEntityPlayerInterface face = ( TileEntityPlayerInterface ) tile ;
if ( face . connectedPlayer = = null ) {
face . connectedPlayer = player . getUniqueID ( ) ;
2016-07-14 02:11:41 +02:00
face . playerName = player . getName ( ) ;
2016-06-05 04:05:37 +02:00
face . markDirty ( ) ;
2016-07-14 02:11:41 +02:00
face . sendUpdate ( ) ;
2016-06-05 04:05:37 +02:00
}
}
super . onBlockPlacedBy ( world , pos , state , player , stack ) ;
}
2016-07-14 02:11:41 +02:00
@Override
@SideOnly ( Side . CLIENT )
public void displayHud ( Minecraft minecraft , EntityPlayer player , ItemStack stack , RayTraceResult posHit , Profiler profiler , ScaledResolution resolution ) {
TileEntity tile = minecraft . theWorld . getTileEntity ( posHit . getBlockPos ( ) ) ;
if ( tile ! = null ) {
if ( tile instanceof TileEntityPlayerInterface ) {
TileEntityPlayerInterface face = ( TileEntityPlayerInterface ) tile ;
String name = face . playerName = = null ? " Unknown " : face . playerName ;
minecraft . fontRendererObj . drawStringWithShadow ( " Bound to: " + TextFormatting . RED + name , resolution . getScaledWidth ( ) / 2 + 5 , resolution . getScaledHeight ( ) / 2 + 5 , StringUtil . DECIMAL_COLOR_WHITE ) ;
minecraft . fontRendererObj . drawStringWithShadow ( " UUID: " + TextFormatting . DARK_GREEN + face . connectedPlayer , resolution . getScaledWidth ( ) / 2 + 5 , resolution . getScaledHeight ( ) / 2 + 15 , StringUtil . DECIMAL_COLOR_WHITE ) ;
}
}
}
2016-06-05 04:05:37 +02:00
}