« Minecraft MOD開発 17 | トップページ | Minecraftとビデオカード »

2014年4月21日 (月)

Minecraft Modding 18

I extends TileEntity and implements IEnergyContainer, IEnergyInterface. canConnect is called. But onExtractEnergy is not called and Minechem 5 doesn's work with my battery. Why?

NishinaCore.java

package nishina;
 
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
 
@Mod(modid = "InfinityBattery", name = "InfinityBattery", version = "1.0")
public class NishinaCore
{
 public static Block blockBattery;
 public static int blockID = 3500;
 
 @EventHandler
 public void preInit(FMLPreInitializationEvent event)
 {
  blockBattery = new BlockBattery( blockID, Material.rock);
  GameRegistry.registerBlock( blockBattery, "BatteryBlock");
 }
 
 @EventHandler
 public void init(FMLInitializationEvent event)
 {
  GameRegistry.registerTileEntity( TileEntityBattery.class, "TileEntityBattery");
 }
}

BlockBattery.java

package nishina;
 
import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.creativetab.*;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.api.energy.*;
import net.minecraftforge.common.ForgeDirection;
 
public class BlockBattery extends BlockContainer
{
 public BlockBattery(int id, Material material)
 {
  super( id, material);
  this.setCreativeTab( CreativeTabs.tabBlock);
  this.setUnlocalizedName( "Battery Block");
  this.setTextureName( "nishina:pink_block");
 }
 
 @Override
 public TileEntity createNewTileEntity(World world)
 {
  return new TileEntityBattery();
 }
}

TileEntityBattery.java

package nishina;
 
import net.minecraft.tileentity.*;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.*;
import universalelectricity.api.energy.*;
 
@UniversalClass
public class TileEntityBattery extends TileEntity implements IEnergyContainer, IEnergyInterface
{
 
 public TileEntityBattery()
 {
  super();
 }
 
 @Override
 public boolean canConnect(ForgeDirection from, Object source)
 {
  System.out.println( "canConnect called.");
  if (from == null || from.equals( ForgeDirection.UNKNOWN))
  {
   return false;
  }
  
  return true;
 }
 
 @Override
 public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
 {
  System.out.println( "onReceiveEnergy called.");
  return receive;
 }
 
 @Override
 public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
 {
  System.out.println( "onExtractEnergy called.");
  return extract;
 }
 
 @Override
 public void setEnergy(ForgeDirection from, long energy)
 {
 }
 
 @Override
 public long getEnergy(ForgeDirection from)
 {
  return Integer.MAX_VALUE;
 }
 
 @Override
 public long getEnergyCapacity(ForgeDirection from)
 {
  return Integer.MAX_VALUE;
 }
 
}

STDOUT

Three injection succeeded.

2014-04-21 20:08:45 [情報] [STDOUT] [Universal Electricity] Injected universalelectricity.core.asm.template.tile.TemplateICTile API into: nishina/TileEntityBattery
2014-04-21 20:08:45 [情報] [STDOUT] [Universal Electricity] Injected universalelectricity.core.asm.template.tile.TemplateBCTile API into: nishina/TileEntityBattery
2014-04-21 20:08:45 [情報] [STDOUT] [Universal Electricity] Injected universalelectricity.core.asm.template.tile.TemplateTETile API into: nishina/TileEntityBattery

Screenshots

Versions

Minecraft: 1.6.4
Forge: 1.6.4-9.11.1.965
UE: 3.1.0.87
JDK: jdk-7u55-windows-x64
OS: Windows 7 64bit Pro

Thanks for reading to the end.

« Minecraft MOD開発 17 | トップページ | Minecraftとビデオカード »

コメント

コメントを書く

コメントは記事投稿者が公開するまで表示されません。

(ウェブ上には掲載しません)

トラックバック

この記事のトラックバックURL:
http://app.f.cocolog-nifty.com/t/trackback/1499066/55878619

この記事へのトラックバック一覧です: Minecraft Modding 18:

« Minecraft MOD開発 17 | トップページ | Minecraftとビデオカード »