本文整理汇总了Java中net.darkhax.tesla.api.ITeslaHolder类的典型用法代码示例。如果您正苦于以下问题:Java ITeslaHolder类的具体用法?Java ITeslaHolder怎么用?Java ITeslaHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ITeslaHolder类属于net.darkhax.tesla.api包,在下文中一共展示了ITeslaHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTooltip
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
/**
* Generates tooltip data for an ItemStack that has the ITeslaHolder interface.
* Additionally, if the holder is a BaseTeslaContainer, input/output rates will be shown.
*
* @param stack The ItemStack to make the tooltip for.
* @param tooltip A list of strings which represent the lines of the tooltip.
*/
@SideOnly(Side.CLIENT)
public static void createTooltip (ItemStack stack, List<String> tooltip) {
if (isTeslaHolder(stack, EnumFacing.DOWN)) {
final KeyBinding keyBindSneak = Minecraft.getMinecraft().gameSettings.keyBindSneak;
final ITeslaHolder holder = TeslaUtils.getTeslaHolder(stack, EnumFacing.DOWN);
if (GameSettings.isKeyDown(keyBindSneak)) {
addHolderInfo(holder, tooltip);
if (holder instanceof BaseTeslaContainer) {
final BaseTeslaContainer container = (BaseTeslaContainer) holder;
tooltip.add(ChatFormatting.DARK_AQUA + I18n.format("tooltip.tesla.input", Long.toString(container.getInputRate())));
tooltip.add(ChatFormatting.DARK_AQUA + I18n.format("tooltip.tesla.output", Long.toString(container.getOutputRate())));
}
}
else {
tooltip.add(I18n.format("tooltip.tesla.showinfo", ChatFormatting.DARK_AQUA, keyBindSneak.getDisplayName(), ChatFormatting.GRAY));
}
}
}
示例2: update
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public void update() {
if (inventory[0] != null && inventory[0].hasCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.DOWN) &&
inventory[0].hasCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN)) {
ITeslaConsumer c = inventory[0].getCapability(TeslaCapabilities.CAPABILITY_CONSUMER, EnumFacing.DOWN);
ITeslaHolder h = inventory[0].getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
if (h.getStoredPower() < h.getCapacity()) container.takePower(c.givePower(Math.min(container.getOutputRate(), container.getStoredPower()), false), false);
}
if(syncTick==10 && !worldObj.isRemote){
if(pos!=null){
int dim = 0;
for(int i : DimensionManager.getIDs())
if(DimensionManager.getWorld(i).equals(worldObj)) {
dim = i;
break;
}
ModSquad.channel.sendToAll(new TileDataSync(pos, serializeNBT().toString(), dim));
}
syncTick = 0;
}else if(syncTick<10) ++syncTick;
}
示例3: drawGuiContainerBackgroundLayer
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
mc.renderEngine.getTexture(grinderGUI);
mc.renderEngine.bindTexture(grinderGUI);
GL11.glColor4f(1f, 1f, 1f, 1f);
drawTexturedModalRect(super.guiLeft, super.guiTop, 0, 0, xSize, ySize);
if (this.grinder.getIsGrinding()) {
drawTexturedModalRect(super.guiLeft + 80, super.guiTop + 35, 177, 14, Math.round(22.0f * this.grinder.getGrinderProgress() / 100.0f), 16);
}
ITeslaHolder tesla = this.grinder.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
if (tesla != null) {
PowerBar bar = new PowerBar(this, super.guiLeft + 8, super.guiTop + 34 - (PowerBar.HEIGHT - 18) / 2, PowerBar.BackgroundType.LIGHT);
bar.draw(tesla);
}
}
示例4: drawGuiContainerBackgroundLayer
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
ResourceLocation texture = new ResourceLocation(ModSquad.MODID, "textures/gui/container/grinder.png");
mc.renderEngine.getTexture(texture);
mc.renderEngine.bindTexture(texture);
GL11.glColor4f(1f, 1f, 1f, 1f);
drawTexturedModalRect(super.guiLeft, super.guiTop, 0, 0, xSize, ySize);
if (this.furnace.getIsSmelting()) {
drawTexturedModalRect(super.guiLeft + 80, super.guiTop + 35, 177, 14, Math.round(22.0f * this.furnace.getSmeltProgress() / 100.0f), 16);
drawTexturedModalRect(super.guiLeft + 57, super.guiTop + 53, 176, 0, 14, 14);
}
ITeslaHolder tesla = this.furnace.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
if (tesla != null) {
PowerBar bar = new PowerBar(this, super.guiLeft + 8, super.guiTop + 34 - (PowerBar.HEIGHT - 18) / 2, PowerBar.BackgroundType.LIGHT);
bar.draw(tesla);
}
}
示例5: preInit
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@EventHandler
public void preInit (FMLPreInitializationEvent event) {
CapabilityManager.INSTANCE.register(ITeslaConsumer.class, new CapabilityTeslaConsumer<ITeslaConsumer>(), BaseTeslaContainer.class);
CapabilityManager.INSTANCE.register(ITeslaProducer.class, new CapabilityTeslaProducer<ITeslaProducer>(), BaseTeslaContainer.class);
CapabilityManager.INSTANCE.register(ITeslaHolder.class, new CapabilityTeslaHolder<ITeslaHolder>(), BaseTeslaContainer.class);
}
示例6: preInit
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@EventHandler
public void preInit (FMLPreInitializationEvent event) {
CapabilityManager.INSTANCE.register(ITeslaConsumer.class, new CapabilityTeslaConsumer<>(), BaseTeslaContainer.class);
CapabilityManager.INSTANCE.register(ITeslaProducer.class, new CapabilityTeslaProducer<>(), BaseTeslaContainer.class);
CapabilityManager.INSTANCE.register(ITeslaHolder.class, new CapabilityTeslaHolder<>(), BaseTeslaContainer.class);
}
示例7: setDamage
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public void setDamage(ItemStack stack, int damage) {
ITeslaHolder h=stack.getCapability(CAPABILITY_HOLDER, EnumFacing.DOWN);
// As stored power increases, dam tends towards the value getMaxDamage()
int dam = h.getCapacity()>0?Math.round(h.getStoredPower()*(getMaxDamage()-1)/h.getCapacity()):1;
try{ itemDamage.setInt(stack, getMaxDamage()-dam); }catch(Exception e){}
}
示例8: setDamage
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public void setDamage(ItemStack stack, int damage) {
ITeslaHolder h=stack.getCapability(CAPABILITY_HOLDER, EnumFacing.DOWN);
// As stored power increases, dam tends towards the value getMaxDamage()
int dam = h.getCapacity()>0?Math.round(h.getStoredPower()*(getMaxDamage()-1)/h.getCapacity()):0;
try{ itemDamage.setInt(stack, getMaxDamage()-dam); }catch(Exception e){}
}
示例9: extractItem
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
ItemStack split;
ITeslaHolder h;
if(inventory[slot]==null || (inventory[0].hasCapability(CAPABILITY_HOLDER, EnumFacing.DOWN)) &&
(h=inventory[0].getCapability(CAPABILITY_HOLDER, EnumFacing.DOWN)).getCapacity()<h.getStoredPower()) return null;
if(amount>=inventory[slot].stackSize){
split = inventory[slot];
if(!simulate) inventory[slot] = null;
return split;
}
if(simulate) (split = inventory[slot].copy()).stackSize = amount;
else split = inventory[slot].splitStack(amount);
return split;
}
示例10: drawGuiContainerForegroundLayer
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
fontRendererObj.drawString("Grinder", 8, 6, 4210751);
ITeslaHolder tesla = this.grinder.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
if (tesla != null) {
String power = TeslaUtils.getDisplayableTeslaCount(tesla.getStoredPower());
String max = TeslaUtils.getDisplayableTeslaCount(tesla.getCapacity());
fontRendererObj.drawString(power + " / " + max, 8, 72, 4210751);
}
}
示例11: drawGuiContainerForegroundLayer
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
fontRendererObj.drawString("Electric Furnace", 8, 6, 4210751);
ITeslaHolder tesla = this.furnace.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, EnumFacing.DOWN);
if (tesla != null) {
String power = TeslaUtils.getDisplayableTeslaCount(tesla.getStoredPower());
String max = TeslaUtils.getDisplayableTeslaCount(tesla.getCapacity());
fontRendererObj.drawString(power + " / " + max, 8, 72, 4210751);
}
}
示例12: update
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public void update()
{
if (attachedTile == null)
{
getAttachedTile();
}
if (connectedCoils != null)
{
IBlockState state = world.getBlockState(pos);
EnumFacing facing = state.getValue(BlockTeslaCoil.FACING);
ITeslaHolder holder = attachedTile.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, facing.getOpposite());
if (hasConnectedCapability(TeslaCapabilities.CAPABILITY_CONSUMER) &&
attachedTile.hasCapability(TeslaCapabilities.CAPABILITY_PRODUCER, facing.getOpposite()) &&
holder.getStoredPower() > 0)
{
List<ITeslaConsumer> consumers = getConnectedCapabilities(TeslaCapabilities.CAPABILITY_CONSUMER);
ITeslaProducer producer = attachedTile.getCapability(TeslaCapabilities.CAPABILITY_PRODUCER, facing.getOpposite());
for(ITeslaConsumer consumer : consumers)
{
producer.takePower(consumer.givePower(producer.takePower(Config.teslaCoilTransferRate, true), false), false);
}
}
}
}
示例13: getCapability
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public IEnergyStorage getCapability(@Nullable ICapabilityProvider provider, @Nullable EnumFacing side) {
if (provider == null) {
return null;
}
ITeslaHolder capHolder = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_HOLDER, "Tesla broke"), side);
ITeslaConsumer capConsumer = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_CONSUMER, "Tesla broke"), side);
ITeslaProducer capProducer = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_PRODUCER, "Tesla broke"), side);
if (capHolder == null && capConsumer == null && capProducer == null) {
return null;
}
return new TeslaToForgeAdapter(capHolder, capConsumer, capProducer);
}
示例14: capRegistered2
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@CapabilityInject(ITeslaHolder.class)
private static void capRegistered2(@Nonnull Capability<ITeslaHolder> cap) {
try {
TeslaAdapter.capRegistered(cap);
} catch (Throwable e) {
Log.error("Tesla API failed to load. Tesla integration disabled. Reason:");
e.printStackTrace();
}
}
示例15: writeNBT
import net.darkhax.tesla.api.ITeslaHolder; //导入依赖的package包/类
@Override
public NBTBase writeNBT (Capability<ITeslaHolder> capability, ITeslaHolder instance, EnumFacing side) {
return null;
}