use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.
the class BlockMachine method recolorBlock.
@Override
public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, EnumDyeColor color) {
MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
if (metaTileEntity == null || metaTileEntity.getPaintingColor() == color.colorValue)
return false;
metaTileEntity.setPaintingColor(color.colorValue);
return true;
}
use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.
the class BlockMachine method onBlockClicked.
@Override
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) {
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
if (metaTileEntity == null)
return;
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
if (rayTraceResult != null) {
metaTileEntity.onCoverLeftClick(playerIn, rayTraceResult);
}
}
use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.
the class BlockMachine method neighborChanged.
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
if (metaTileEntity != null) {
metaTileEntity.updateInputRedstoneSignals();
metaTileEntity.onNeighborChanged();
}
}
use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.
the class BlockMachine method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
CuboidRayTraceResult rayTraceResult = (CuboidRayTraceResult) RayTracer.retraceBlock(worldIn, playerIn, pos);
ItemStack itemStack = playerIn.getHeldItem(hand);
if (metaTileEntity == null || rayTraceResult == null) {
return false;
}
if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null)) {
IScrewdriverItem screwdriver = itemStack.getCapability(GregtechCapabilities.CAPABILITY_SCREWDRIVER, null);
if (screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, true) && metaTileEntity.onCoverScrewdriverClick(playerIn, hand, rayTraceResult)) {
screwdriver.damageItem(DamageValues.DAMAGE_FOR_SCREWDRIVER, false);
return true;
}
return false;
}
if (itemStack.hasCapability(GregtechCapabilities.CAPABILITY_WRENCH, null)) {
IWrenchItem wrenchItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_WRENCH, null);
EnumFacing wrenchDirection = ICoverable.determineGridSideHit(rayTraceResult);
if (wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, true) && metaTileEntity.onWrenchClick(playerIn, hand, wrenchDirection, rayTraceResult)) {
wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, false);
return true;
}
return false;
}
return metaTileEntity.onCoverRightClick(playerIn, hand, rayTraceResult);
}
use of gregtech.api.metatileentity.MetaTileEntity in project GregTech by GregTechCE.
the class MachineItemBlock method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
MetaTileEntity metaTileEntity = getMetaTileEntity(stack);
if (metaTileEntity == null)
return;
// item specific tooltip like: gregtech.machine.lathe.lv.tooltip
String tooltipLocale = metaTileEntity.getMetaName() + ".tooltip";
if (I18n.hasKey(tooltipLocale)) {
String[] lines = I18n.format(tooltipLocale).split("/n");
tooltip.addAll(Arrays.asList(lines));
}
// tier less tooltip for a electric machine like: gregtech.machine.lathe.tooltip
if (metaTileEntity instanceof ITieredMetaTileEntity) {
String tierlessTooltipLocale = ((ITieredMetaTileEntity) metaTileEntity).getTierlessTooltipKey();
// case when it's not true would be any machine extending from TieredMetaTileEntity but having only one tier
if (!tooltipLocale.equals(tierlessTooltipLocale) && I18n.hasKey(tierlessTooltipLocale)) {
String[] lines = I18n.format(tierlessTooltipLocale).split("/n");
tooltip.addAll(Arrays.asList(lines));
}
}
metaTileEntity.addInformation(stack, worldIn, tooltip, flagIn.isAdvanced());
if (flagIn.isAdvanced()) {
tooltip.add(String.format("MetaTileEntity Id: %s", metaTileEntity.metaTileEntityId.toString()));
}
}
Aggregations