2015-04-26 20:07:57 +02:00
|
|
|
package ellpeck.actuallyadditions.blocks;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-05-25 17:00:54 +02:00
|
|
|
import ellpeck.actuallyadditions.ActuallyAdditions;
|
2015-06-06 01:25:53 +02:00
|
|
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
2015-05-25 17:00:54 +02:00
|
|
|
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
|
|
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
2015-05-20 22:39:43 +02:00
|
|
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
2015-06-18 13:14:57 +02:00
|
|
|
import ellpeck.actuallyadditions.util.*;
|
2015-04-26 20:07:57 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2015-05-20 22:39:43 +02:00
|
|
|
import net.minecraft.util.ChatComponentText;
|
2015-04-26 20:07:57 +02:00
|
|
|
import net.minecraft.util.IIcon;
|
2015-05-20 22:39:43 +02:00
|
|
|
import net.minecraft.util.StatCollector;
|
2015-07-07 20:20:24 +02:00
|
|
|
import net.minecraft.util.Vec3;
|
2015-04-26 20:07:57 +02:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-05-20 22:39:43 +02:00
|
|
|
public class BlockPhantomface extends BlockContainerBase implements INameableItem{
|
2015-04-26 20:07:57 +02:00
|
|
|
|
2015-05-25 17:00:54 +02:00
|
|
|
public static final int FACE = 0;
|
|
|
|
public static final int PLACER = 1;
|
|
|
|
public static final int BREAKER = 2;
|
2015-05-27 21:57:53 +02:00
|
|
|
public static final int LIQUIFACE = 3;
|
|
|
|
public static final int ENERGYFACE = 4;
|
2015-05-25 17:00:54 +02:00
|
|
|
|
|
|
|
public int type;
|
2015-06-06 01:25:53 +02:00
|
|
|
public int range;
|
2015-05-25 17:00:54 +02:00
|
|
|
|
|
|
|
public BlockPhantomface(int type){
|
2015-05-20 22:39:43 +02:00
|
|
|
super(Material.rock);
|
2015-05-25 17:00:54 +02:00
|
|
|
this.type = type;
|
2015-05-20 22:39:43 +02:00
|
|
|
this.setHarvestLevel("pickaxe", 0);
|
2015-07-07 01:13:39 +02:00
|
|
|
this.setHardness(4.5F);
|
|
|
|
this.setResistance(10.0F);
|
2015-05-20 22:39:43 +02:00
|
|
|
this.setStepSound(soundTypeStone);
|
2015-06-06 01:25:53 +02:00
|
|
|
|
|
|
|
if(type == FACE || type == LIQUIFACE || type == ENERGYFACE) this.range = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
|
|
|
else if(type == BREAKER || type == PLACER) this.range = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue();
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
2015-05-25 17:00:54 +02:00
|
|
|
@Override
|
|
|
|
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
|
|
|
if(this.type == PLACER || this.type == BREAKER) this.dropInventory(world, x, y, z);
|
|
|
|
super.breakBlock(world, x, y, z, block, par6);
|
|
|
|
}
|
|
|
|
|
2015-04-26 20:07:57 +02:00
|
|
|
@Override
|
2015-05-20 22:39:43 +02:00
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ){
|
|
|
|
if(!world.isRemote){
|
2015-05-25 17:00:54 +02:00
|
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
2015-05-20 22:39:43 +02:00
|
|
|
if(tile != null){
|
2015-05-25 17:00:54 +02:00
|
|
|
if(tile instanceof TileEntityPhantomface){
|
|
|
|
TileEntityPhantomface phantom = (TileEntityPhantomface)tile;
|
2015-06-12 19:12:06 +02:00
|
|
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
2015-05-25 17:00:54 +02:00
|
|
|
if(phantom.hasBoundTile()){
|
2015-07-07 20:20:24 +02:00
|
|
|
int distance = (int)Vec3.createVectorHelper(x, y, z).distanceTo(Vec3.createVectorHelper(phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ()));
|
2015-07-20 06:39:52 +02:00
|
|
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", phantom.boundPosition.getItemBlock().getItemStackDisplayName(new ItemStack(phantom.boundPosition.getBlock(), 1, phantom.boundPosition.getMetadata())), phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ(), distance)));
|
2015-07-07 20:20:24 +02:00
|
|
|
|
|
|
|
if(phantom.isBoundTileInRage()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc")));
|
|
|
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
2015-05-20 22:39:43 +02:00
|
|
|
}
|
2015-05-25 17:00:54 +02:00
|
|
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(tile instanceof TileEntityPhantomPlacer){
|
|
|
|
if(player.isSneaking()){
|
|
|
|
TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile;
|
2015-06-12 19:12:06 +02:00
|
|
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range));
|
2015-05-25 17:00:54 +02:00
|
|
|
if(phantom.hasBoundPosition()){
|
2015-07-07 20:20:24 +02:00
|
|
|
int distance = (int)Vec3.createVectorHelper(x, y, z).distanceTo(Vec3.createVectorHelper(phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ()));
|
2015-07-20 06:39:52 +02:00
|
|
|
player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", phantom.boundPosition.getItemBlock().getItemStackDisplayName(new ItemStack(phantom.boundPosition.getBlock(), 1, phantom.boundPosition.getMetadata())), phantom.boundPosition.getX(), phantom.boundPosition.getY(), phantom.boundPosition.getZ(), distance)));
|
2015-07-07 20:20:24 +02:00
|
|
|
|
|
|
|
if(phantom.isBoundPositionInRange()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc")));
|
|
|
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
|
2015-05-25 17:00:54 +02:00
|
|
|
}
|
|
|
|
else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
|
|
|
|
}
|
2015-07-17 09:03:31 +02:00
|
|
|
else player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.PHANTOM_PLACER.ordinal(), world, x, y, z);
|
2015-05-20 22:39:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-25 17:00:54 +02:00
|
|
|
return true;
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-05-20 22:39:43 +02:00
|
|
|
public TileEntity createNewTileEntity(World world, int par2){
|
2015-05-25 17:00:54 +02:00
|
|
|
switch(this.type){
|
|
|
|
case PLACER:
|
|
|
|
return new TileEntityPhantomPlacer();
|
|
|
|
case BREAKER:
|
|
|
|
return new TileEntityPhantomPlacer.TileEntityPhantomBreaker();
|
2015-05-27 21:57:53 +02:00
|
|
|
case LIQUIFACE:
|
|
|
|
return new TileEntityPhantomface.TileEntityPhantomLiquiface();
|
2015-05-29 18:17:28 +02:00
|
|
|
case ENERGYFACE:
|
|
|
|
return new TileEntityPhantomface.TileEntityPhantomEnergyface();
|
2015-05-25 17:00:54 +02:00
|
|
|
default:
|
2015-05-27 21:57:53 +02:00
|
|
|
return new TileEntityPhantomface.TileEntityPhantomItemface();
|
2015-05-25 17:00:54 +02:00
|
|
|
}
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-05-20 22:39:43 +02:00
|
|
|
public IIcon getIcon(int side, int metadata){
|
|
|
|
return this.blockIcon;
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-05-20 22:39:43 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister iconReg){
|
|
|
|
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName());
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName(){
|
2015-05-27 21:57:53 +02:00
|
|
|
switch(this.type){
|
|
|
|
case PLACER:
|
|
|
|
return "blockPhantomPlacer";
|
|
|
|
case BREAKER:
|
|
|
|
return "blockPhantomBreaker";
|
|
|
|
case LIQUIFACE:
|
|
|
|
return "blockPhantomLiquiface";
|
2015-05-29 18:17:28 +02:00
|
|
|
case ENERGYFACE:
|
|
|
|
return "blockPhantomEnergyface";
|
2015-05-27 21:57:53 +02:00
|
|
|
default:
|
|
|
|
return "blockPhantomface";
|
|
|
|
}
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class TheItemBlock extends ItemBlock{
|
|
|
|
|
|
|
|
private Block theBlock;
|
|
|
|
|
|
|
|
public TheItemBlock(Block block){
|
|
|
|
super(block);
|
|
|
|
this.theBlock = block;
|
|
|
|
this.setHasSubtypes(false);
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
2015-05-20 22:39:43 +02:00
|
|
|
return EnumRarity.epic;
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
|
|
|
return this.getUnlocalizedName();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SideOnly(Side.CLIENT)
|
2015-06-18 13:14:57 +02:00
|
|
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
|
|
|
BlockUtil.addInformation(theBlock, list, 2, "");
|
|
|
|
if(KeyUtil.isShiftPressed()){
|
|
|
|
if(((BlockPhantomface)this.theBlock).type == LIQUIFACE){
|
|
|
|
list.add(StringUtil.ORANGE+StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.3"));
|
|
|
|
list.add(StringUtil.ORANGE+StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.4"));
|
|
|
|
}
|
|
|
|
list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + ((BlockPhantomface)theBlock).range);
|
|
|
|
}
|
2015-04-26 20:07:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMetadata(int damage){
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
}
|
2015-05-27 21:57:53 +02:00
|
|
|
}
|