[解決済み]MOD制作での独自GUIに関する質問

Modding・サーバPlugin制作・ツール制作など、開発関連の質問があればこちらにお願い致します。
フォーラムルール
質問関連フォーラムで質問する時は、必ず次のトピックを一読/厳守お願い致します。
viewtopic.php?f=5&t=999
  • (PostNo.289356)

[解決済み]MOD制作での独自GUIに関する質問

投稿記事by tetetetoto » 2016年12月04日(日) 02:23

以下開発環境です。
eclipse 4.6
Minecraft 1.7.10
Minecraft Forge 1558

特定のTileEntityのGUIが開けません。
CoreModのインスタンスとMODIDの相違もなく、
他のアイテムのGUI、TileEntityのGUIは開くことができる状態です。

クラッシュレポートから、コアモッドのインスタンスの型が問題かと思い調べ尽くし試行錯誤しましたが、症状は変わりませんでした。
他のGUI(TileEntity含む)のGUIは開けるので、原因がまったく掴めません。

足りない情報があれば、開示いたします。
質問の趣旨に関連する処理部分を一部赤文字にしています。

よろしくお願いします。

クラッシュレポートです
---- Minecraft Crash Report ----
// I bet Cylons wouldn't have this problem.

Time: 16/12/04 2:08
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265)
at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
at com.chicken.blocks.stone.BlockStoneDevices.onBlockActivated(BlockStoneDevices.java:170)
at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376)
at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
at net.minecraft.client.Minecraft.run(Minecraft.java:962)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265)
at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
at com.chicken.blocks.stone.BlockStoneDevices.onBlockActivated(BlockStoneDevices.java:170)
at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376)
at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Lemon1232'/170, l='MpServer', x=-195.05, y=5.62, z=36.76]]
Chunk stats: MultiplayerChunkCache: 624, 624
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options:
Level spawn location: World: (-200,4,26), Chunk: (at 8,0,10 in -13,1; contains blocks -208,0,16 to -193,255,31), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Level time: 2819 game time, 2819 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 85 total; [EntityPig['Pig'/128, l='MpServer', x=-156.50, y=4.00, z=51.50], EntityChicken['Chicken'/129, l='MpServer', x=-129.44, y=4.00, z=-39.47], EntityChicken['Chicken'/130, l='MpServer', x=-135.38, y=4.00, z=-31.56], EntityCow['Cow'/131, l='MpServer', x=-133.97, y=4.00, z=-5.94], EntitySheep['Sheep'/132, l='MpServer', x=-128.06, y=4.00, z=6.16], EntityCow['Cow'/133, l='MpServer', x=-132.34, y=4.00, z=6.31], EntityCow['Cow'/134, l='MpServer', x=-129.41, y=4.00, z=2.16], EntityCow['Cow'/135, l='MpServer', x=-130.59, y=4.00, z=1.50], EntityCow['Cow'/136, l='MpServer', x=-133.53, y=4.00, z=4.56], EntityChicken['Chicken'/137, l='MpServer', x=-121.44, y=4.00, z=-45.41], EntitySheep['Sheep'/139, l='MpServer', x=-118.28, y=4.00, z=-33.59], EntityChicken['Chicken'/140, l='MpServer', x=-119.50, y=4.00, z=-32.50], EntityChicken['Chicken'/141, l='MpServer', x=-120.53, y=4.00, z=-34.38], EntityChicken['Chicken'/142, l='MpServer', x=-118.81, y=4.00, z=-32.72], EntitySheep['Sheep'/143, l='MpServer', x=-120.59, y=4.00, z=-30.16], EntityChicken['Chicken'/144, l='MpServer', x=-118.59, y=4.00, z=-20.59], EntitySheep['Sheep'/145, l='MpServer', x=-117.97, y=4.00, z=-31.25], EntityCow['Cow'/146, l='MpServer', x=-132.81, y=4.00, z=1.09], EntityCow['Cow'/149, l='MpServer', x=-123.03, y=4.00, z=11.91], EntityCow['Cow'/150, l='MpServer', x=-121.91, y=4.00, z=2.16], EntitySheep['Sheep'/151, l='MpServer', x=-126.22, y=4.00, z=5.94], EntitySheep['Sheep'/35, l='MpServer', x=-273.03, y=4.00, z=-25.44], EntityClientPlayerMP['Lemon1232'/170, l='MpServer', x=-195.05, y=5.62, z=36.76], EntitySheep['Sheep'/42, l='MpServer', x=-275.97, y=4.00, z=-38.97], EntitySheep['Sheep'/43, l='MpServer', x=-269.56, y=4.00, z=-35.75], EntitySheep['Sheep'/44, l='MpServer', x=-268.91, y=4.00, z=-32.50], EntityChicken['Chicken'/45, l='MpServer', x=-265.47, y=4.00, z=-37.41], EntitySheep['Sheep'/46, l='MpServer', x=-263.81, y=4.00, z=-32.88], EntitySheep['Sheep'/47, l='MpServer', x=-260.09, y=4.00, z=-33.97], EntityChicken['Chicken'/48, l='MpServer', x=-267.38, y=4.00, z=-35.81], EntitySheep['Sheep'/49, l='MpServer', x=-268.38, y=4.00, z=-35.13], EntityChicken['Chicken'/50, l='MpServer', x=-264.22, y=4.00, z=-29.44], EntityChicken['Chicken'/51, l='MpServer', x=-265.63, y=4.00, z=-18.44], EntitySheep['Sheep'/52, l='MpServer', x=-259.91, y=4.00, z=-25.91], EntitySheep['Sheep'/53, l='MpServer', x=-264.81, y=4.00, z=-28.19], EntityCow['Cow'/54, l='MpServer', x=-261.81, y=4.00, z=-16.13], EntitySheep['Sheep'/55, l='MpServer', x=-256.78, y=4.00, z=-14.97], EntitySheep['Sheep'/56, l='MpServer', x=-263.91, y=4.00, z=57.03], EntitySheep['Sheep'/57, l='MpServer', x=-271.31, y=4.00, z=44.19], EntityPig['Pig'/58, l='MpServer', x=-260.31, y=4.00, z=56.56], EntityPig['Pig'/59, l='MpServer', x=-262.94, y=4.00, z=68.06], EntitySheep['Sheep'/60, l='MpServer', x=-263.59, y=4.00, z=61.13], EntityPig['Pig'/61, l='MpServer', x=-261.97, y=4.00, z=63.31], EntitySheep['Sheep'/62, l='MpServer', x=-263.81, y=4.00, z=63.91], EntityChicken['Chicken'/63, l='MpServer', x=-265.44, y=4.00, z=76.34], EntityChicken['Chicken'/64, l='MpServer', x=-256.50, y=4.00, z=66.50], EntityChicken['Chicken'/69, l='MpServer', x=-242.22, y=4.00, z=-40.72], EntitySheep['Sheep'/70, l='MpServer', x=-247.38, y=4.00, z=-15.22], EntitySheep['Sheep'/71, l='MpServer', x=-248.16, y=4.00, z=-31.13], EntityPig['Pig'/72, l='MpServer', x=-247.69, y=4.00, z=-26.59], EntityPig['Pig'/73, l='MpServer', x=-248.84, y=4.00, z=-27.81], EntityPig['Pig'/74, l='MpServer', x=-242.38, y=4.00, z=-26.31], EntityPig['Pig'/75, l='MpServer', x=-244.47, y=4.00, z=-23.19], EntityCow['Cow'/76, l='MpServer', x=-255.03, y=4.00, z=-19.88], EntityCow['Cow'/77, l='MpServer', x=-254.88, y=4.00, z=-13.75], EntityCow['Cow'/78, l='MpServer', x=-249.22, y=4.00, z=-15.13], EntityChicken['Chicken'/79, l='MpServer', x=-246.53, y=4.00, z=61.53], EntityChicken['Chicken'/80, l='MpServer', x=-254.13, y=4.00, z=72.41], EntityCow['Cow'/84, l='MpServer', x=-231.91, y=4.00, z=-42.16], EntityCow['Cow'/85, l='MpServer', x=-230.75, y=4.00, z=-43.28], EntityCow['Cow'/90, l='MpServer', x=-222.78, y=4.00, z=-38.81], EntityChicken['Chicken'/92, l='MpServer', x=-196.47, y=4.00, z=1.63], EntitySheep['Sheep'/93, l='MpServer', x=-189.06, y=4.00, z=44.94], EntityHorse['Horse'/94, l='MpServer', x=-191.13, y=4.00, z=43.97], EntityHorse['Horse'/95, l='MpServer', x=-193.78, y=4.00, z=77.72], EntityHorse['Horse'/96, l='MpServer', x=-180.81, y=4.00, z=78.88], EntitySheep['Sheep'/97, l='MpServer', x=-185.78, y=4.00, z=71.72], EntitySheep['Sheep'/98, l='MpServer', x=-178.78, y=4.00, z=78.84], EntitySheep['Sheep'/99, l='MpServer', x=-183.22, y=4.00, z=62.72], EntityPig['Pig'/100, l='MpServer', x=-184.47, y=4.00, z=80.94], EntityPig['Pig'/101, l='MpServer', x=-182.63, y=4.00, z=80.19], EntityPig['Pig'/109, l='MpServer', x=-166.09, y=4.00, z=-7.88], EntityHorse['Horse'/110, l='MpServer', x=-169.47, y=4.00, z=15.25], EntityChicken['Chicken'/111, l='MpServer', x=-158.63, y=4.00, z=29.41], EntityHorse['Horse'/112, l='MpServer', x=-171.50, y=4.00, z=64.50], EntityHorse['Horse'/113, l='MpServer', x=-166.06, y=4.00, z=61.91], EntitySheep['Sheep'/114, l='MpServer', x=-173.35, y=4.00, z=57.39], EntityPig['Pig'/115, l='MpServer', x=-162.09, y=4.00, z=55.09], EntityHorse['Horse'/116, l='MpServer', x=-175.87, y=4.00, z=73.13], EntitySheep['Sheep'/117, l='MpServer', x=-174.28, y=4.00, z=75.22], EntityPig['Pig'/118, l='MpServer', x=-175.97, y=4.00, z=77.09], EntityPig['Pig'/119, l='MpServer', x=-171.91, y=4.00, z=88.94], EntitySheep['Sheep'/120, l='MpServer', x=-164.13, y=4.00, z=85.25], EntityPig['Pig'/126, l='MpServer', x=-154.13, y=4.00, z=54.84], EntityPig['Pig'/127, l='MpServer', x=-153.03, y=4.00, z=56.56]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Integrated singleplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566)
at net.minecraft.client.Minecraft.run(Minecraft.java:991)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 10 (amd64) version 10.0
Java Version: 1.8.0_102, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 3263117136 bytes (3111 MB) / 3926917120 bytes (3745 MB) up to 3926917120 bytes (3745 MB)
JVM Flags: 4 total; -Xms4G -Xmx4G -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=512M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 10 mods loaded, 10 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar)
UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar)
UCHIJAAAA CodeChickenCore{1.0.4.35} [CodeChicken Core] (minecraft.jar)
UCHIJAAAA NotEnoughItems{1.0.4.83} [Not Enough Items] (NotEnoughItems-1.7.10-1.0.4.83-universal.jar)
UCHIJAAAA examplemod{1.0} [Example Mod] (bin)
UCHIJAAAA Chicken IO{Alpha} [Chicken IO] (bin)
UCHIJAAAA NBTEdit{1.7.10} [In-game NBTEdit] (ForgeNBTEdit-universal-1.0.0.test.jar)
UCHIJAAAA ImmersiveEngineering{0.7.7} [Immersive Engineering] (ImmersiveEngineering-0.7.7-deobf (1).jar)
UCHIJAAAA Waila{1.5.8} [Waila] (Waila-1.5.9_1.7.10.jar)
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.14008 Compatibility Profile Context 21.19.137.1' Renderer: 'AMD Radeon R9 200 Series'
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: AMD Radeon R9 200 Series GL version 4.5.14008 Compatibility Profile Context 21.19.137.1, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)


CoreMod ソースコード
package com.chicken;
import com.chicken.enchantment.EnchantStrength;
import com.chicken.network.PacketHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraftforge.common.config.Configuration;

@Mod(modid = ChickenIO.MOD_ID, version = ChickenIO.VERSION)
public class ChickenIO {


@Mod.Instance("Chicken IO")
public static ChickenIO Instance;
public static final String MOD_ID = "Chicken IO";
public static final String VERSION = "Alpha";

@SidedProxy(clientSide = "com.chicken.ClientProxy", serverSide = "com.chicken.CommonProxy")
public static CommonProxy proxy;

public static final String networkChannelName = "ChickenNC";
public static SimpleNetworkWrapper network;

public static Enchantment strength;

public static int strengthID = 160;

public static boolean debug = false;

@EventHandler
public void preInit(FMLPreInitializationEvent e){
Configuration config = new Configuration(e.getSuggestedConfigurationFile());

try{
config.load();
}catch (Exception excep){}finally{
config.save();
}

proxy.preInit(e);
ChickenRegistry.preInit();
PacketHandler.init();
}

@EventHandler
public void Init(FMLPreInitializationEvent e){
ChickenRegistry.init();
strength = new EnchantStrength(strengthID, 10).setName("chicken.strength");
NetworkRegistry.INSTANCE.registerGuiHandler(Instance, proxy);
proxy.init();
proxy.registerRenderers();
}

@EventHandler
public void postInitialise(FMLPostInitializationEvent e){

}

public static CreativeTabs chickenTab = new CreativeTabs("chickenTab"){
public Item getTabIconItem(){
return Items.chicken;
}
};
}


GUIを開くとクラッシュするTileEntityのブロックのソースコード
package com.chicken.blocks.stone;

import java.util.ArrayList;
import java.util.List;

import com.chicken.ChickenRegistry;
import com.chicken.blocks.BlockBase;
import com.chicken.render.BlockRenderStoneDevices;
import com.chicken.tileentity.TileEntityMultiblockPart;
import com.chicken.tileentity.tile.TileStation;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

public class BlockStoneMachines extends BlockBase {

IIcon[] iconsBlastFurnace = new IIcon[2];

public BlockStoneMachines()
{
super("stoneMachine", Material.rock, 1, ItemBlockStoneMachines.class, new String[] { "station" });
setHardness(2.0F);
setResistance(20.0F);
}

public void getSubBlocks(Item item, CreativeTabs tab, List list)
{
list.add(new ItemStack(item, 1, 4));
}

public int getRenderType()
{
return BlockRenderStoneDevices.renderID;
}

public boolean canRenderInPass(int pass)
{
BlockRenderStoneDevices.renderPass = pass;
return true;
}

public boolean isOpaqueCube()
{
return false;
}

public boolean renderAsNormalBlock()
{
return false;
}

public int getRenderBlockPass()
{
return 1;
}

public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
{
if ((metadata == 0) || (metadata == 2) || (metadata == 5)) {
return new ArrayList();
}
return super.getDrops(world, x, y, z, metadata, fortune);
}

public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player)
{
return getOriginalBlock(world, x, y, z);
}

public ItemStack getOriginalBlock(World world, int x, int y, int z)
{
TileEntity te = world.getTileEntity(x, y, z);
if ((te instanceof TileEntityMultiblockPart)) {
return ((TileEntityMultiblockPart)te).getOriginalBlock();
}
return new ItemStack(this, 0, world.getBlockMetadata(x, y, z));
}

public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
{
return true;
}

public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
TileEntity te = world.getTileEntity(x, y, z);
if ((te instanceof TileEntityMultiblockPart))
{
float[] bounds = ((TileEntityMultiblockPart)te).getBlockBounds();
if ((bounds != null) && (bounds.length > 5)) {
setBlockBounds(bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
} else {
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
else
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}

public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}

public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z)
{
setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
for (int i = 0; i < this.icons.length; i++) {
this.icons[i][0] = iconRegister.registerIcon("chicken:" + this.name + "_" + this.subNames[i]);
}
this.iconsBlastFurnace[0] = iconRegister.registerIcon("chicken:" + this.name + "_station_off");
this.iconsBlastFurnace[1] = iconRegister.registerIcon("chicken:" + this.name + "_station_on");;
}

@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
TileEntity te = world.getTileEntity(x, y, z);
if (((te instanceof TileStation)) && (((TileStation)te).formed))
{
int[] off = ((TileStation)te).offset;
if (off[1] != 0) {
return super.getIcon(world, x, y, z, side);
}
TileStation tebf = (TileStation)te;
if (tebf.master() == null) {
return this.iconsBlastFurnace[0];
}
}
return super.getIcon(world, x, y, z, side);
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
TileEntity curr = world.getTileEntity(x, y, z);
if ((curr instanceof TileStation)) {
if ((!player.isSneaking()) && (((TileStation)curr).formed))
{
TileStation te = ((TileStation)curr).master();
if (te == null) {
te = (TileStation)curr;
}
if(world.isRemote)
player.openGui(ChickenRegistry.instance, 15, world, te.xCoord, te.yCoord, te.zCoord);
return true;
}
}
return false;
}


public void breakBlock(World world, int x, int y, int z, Block par5, int par6)
{
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (((tileEntity instanceof TileEntityMultiblockPart)) && ((tileEntity instanceof IInventory))) {
if ((!world.isRemote) && (((TileEntityMultiblockPart)tileEntity).formed))
{
TileEntity master = ((TileEntityMultiblockPart)tileEntity).master();
if (master == null) {
master = tileEntity;
}
for (int i = 0; i < ((IInventory)master).getSizeInventory(); i++)
{
ItemStack stack = ((IInventory)master).getStackInSlot(i);
if (stack != null)
{
float fx = world.rand.nextFloat() * 0.8F + 0.1F;
float fz = world.rand.nextFloat() * 0.8F + 0.1F;

EntityItem entityitem = new EntityItem(world, x + fx, y + 0.5D, z + fz, stack);
entityitem.motionX = (world.rand.nextGaussian() * 0.05D);
entityitem.motionY = (world.rand.nextGaussian() * 0.05D + 0.2D);
entityitem.motionZ = (world.rand.nextGaussian() * 0.05D);
if (stack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
}
world.spawnEntityInWorld(entityitem);
}
}
}
}
}

public boolean hasTileEntity(int meta)
{
return (meta == 0) || (meta == 2) || (meta == 5);
}

public TileEntity createNewTileEntity(World world, int meta)
{
switch (meta)
{
case 0:
return new TileStation();
}
return null;
}


ClientProxy ソースコード
package com.chicken;
import org.lwjgl.input.Keyboard;

import com.chicken.gui.ContainerStation;
import com.chicken.gui.GuiBackPack;
import com.chicken.gui.GuiStation;
import com.chicken.render.BlockRenderMetalMultiblocks;
import com.chicken.render.BlockRenderStoneDevices;
import com.chicken.testttttttttttttttttttt.GuiEggCollector;
import com.chicken.testttttttttttttttttttt.TileEggCollector;
import com.chicken.tileentity.tile.TileStation;

import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class ClientProxy extends CommonProxy{

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);

if((ID == 1)){
return new GuiStation(new ContainerStation());
//return new GuiStation(player.inventory, (TileStation)tile);
}
if(ID == 2){
return new GuiBackPack(player.inventory, world);
}
if(ID == 3){
return new GuiEggCollector(player.inventory, (TileEggCollector)tile);
}
return null;
}


@Override
public boolean isShiftKeyDown() {
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
}

@Override
public void registerRenderers(){
RenderingRegistry.registerBlockHandler(new BlockRenderMetalMultiblocks());
RenderingRegistry.registerBlockHandler(new BlockRenderStoneDevices());
}

public void registerTileEntity(){
}
}


CommonProxy ソースコード
package com.chicken;

import com.chicken.gui.ContainerBackPack;
import com.chicken.gui.ContainerStation;
import com.chicken.gui.GuiStation;
import com.chicken.network.ButtonPacket;
import com.chicken.testttttttttttttttttttt.ContainerEggCollector;
import com.chicken.testttttttttttttttttttt.TileEggCollector;
import com.chicken.tileentity.tile.TileStation;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class CommonProxy implements IGuiHandler{

public void init() {}

public void preInit(FMLPreInitializationEvent event){
initializeNetwork();
}

public void initializeNetwork(){
ChickenIO.network = NetworkRegistry.INSTANCE.newSimpleChannel(ChickenIO.networkChannelName);
ChickenIO.network.registerMessage(ButtonPacket.Handler.class, ButtonPacket.class, 2, Side.SERVER);
}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);

if((ID == 1)){
return new ContainerStation();
//return new ContainerStation(player.inventory, (TileStation)tile);
}
if(ID == 2){
return new ContainerBackPack(player.inventory, world);
}
if(ID == 3){
return new ContainerEggCollector(player.inventory, (TileEggCollector)tile);
}
return null;
}


public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){
return null;
}

public boolean isShiftKeyDown() {
return false;
}

public void registerRenderers(){

}

public void registerTileEntity(){

}
}
最後に編集したユーザー tetetetoto [ 2016年12月04日(日) 16:54 ], 累計 1 回
アバター
tetetetoto
ID:bfa92515
木を殴ってる
 
記事: 11
登録日時: 2014年10月28日(火) 17:43

  • (PostNo.289357)

Re: MOD制作での独自GUIに関する質問

投稿記事by zyando123 » 2016年12月04日(日) 02:58

> at com.chicken.blocks.stone.BlockStoneDevices.onBlockActivated(BlockStoneDevices.java:170)から
BlockStoneDevicesというクラスでNullPointerExceptionが発生しているようですので、BlockStoneDevicesのソースコードをお願いします。
ろくな事を呟かないTwitterアカウント→@zyando79
アバター
zyando123
ID:93d451bf
石掘り
 
記事: 92
登録日時: 2016年8月29日(月) 13:28

  • (PostNo.289360)

Re: MOD制作での独自GUIに関する質問

投稿記事by tetetetoto » 2016年12月04日(日) 04:45

zyando123 さんが書きました:> at com.chicken.blocks.stone.BlockStoneDevices.onBlockActivated(BlockStoneDevices.java:170)から
BlockStoneDevicesというクラスでNullPointerExceptionが発生しているようですので、BlockStoneDevicesのソースコードをお願いします。


紛らわしくてごめんなさい。
直後にクラスの名前を変更したので、

GUIを開くとクラッシュするTileEntityのブロックのソースコード

の方にBlockStoneMachinesとして記載しております。
アバター
tetetetoto
ID:bfa92515
木を殴ってる
 
記事: 11
登録日時: 2014年10月28日(火) 17:43

  • (PostNo.289372)

Re: MOD制作での独自GUIに関する質問

投稿記事by zyando123 » 2016年12月04日(日) 11:50

EntityPlayer#openGui(Object, int, World, int, int, int)の第一引数にはModのインスタンスが必要ですので、@Modが記述されているクラスのインスタンスを渡すようにして下さい。
ろくな事を呟かないTwitterアカウント→@zyando79
アバター
zyando123
ID:93d451bf
石掘り
 
記事: 92
登録日時: 2016年8月29日(月) 13:28

  • (PostNo.289410)

Re: MOD制作での独自GUIに関する質問

投稿記事by tetetetoto » 2016年12月04日(日) 16:53

zyando123 さんが書きました:EntityPlayer#openGui(Object, int, World, int, int, int)の第一引数にはModのインスタンスが必要ですので、@Modが記述されているクラスのインスタンスを渡すようにして下さい。


ウッカリしていました><
本当にありがとうございます。
アバター
tetetetoto
ID:bfa92515
木を殴ってる
 
記事: 11
登録日時: 2014年10月28日(火) 17:43


Return to 質問:開発・制作関連

x