timaxa007 написал(а):minecraft forge custom furnace - поиск по поисковику, даже на YouTube есть уроки.
http://bedrockminer.jimdo.com/modding-tutorials/advanced-modding/gui-container/
timaxa007 написал(а):Если ты про урок от _Bedrock_Miner_, то вроде там основы расписаны (хотя я в них вникать не стал).
Изучаешь как делать GuiHandler, а код можно брать от ванильной печи.
timaxa007 написал(а):net.minecraft.block.BlockFurnace
net.minecraft.tileentity.TileEntityFurnace
net.minecraft.item.crafting.FurnaceRecipes
net.minecraft.inventory.ContainerFurnace
net.minecraft.client.gui.inventory.GuiFurnace
timaxa007 написал(а):В исходниках.
Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
vites написал(а):Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
всё понял спасибо
vites написал(а):Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
всё понял спасибо
vites написал(а):Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
всё понял спасибо
аааааааааа не чего не понял что куда кидать!
Я кидал, переделовал но нечего не смог, не могу зарегистрировать печку или там тайлы!Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
package com.Savage.redpw.gui;
import com.Savage.redpw.BlinkingTileEntity;
import com.Savage.redpw.Main;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class GuiHundler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID)
{
case 0: return new ChemaConteiner(player.inventory, (BlinkingTileEntity) world.getTileEntity(new BlockPos(x, y, z)));
default: return null;
}
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch(ID)
{
case 0: return new GiuChema(new ChemaConteiner(player.inventory, (BlinkingTileEntity) world.getTileEntity(new BlockPos(x, y, z))), (BlinkingTileEntity) world.getTileEntity(new BlockPos(x, y, z)));
default: return null;
}
}
}
package com.Savage.redpw.gui;
import com.Savage.redpw.BlinkingTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class GiuChema extends GuiContainer{
public BlinkingTileEntity tile;
public static final ResourceLocation F_GUI = new ResourceLocation("redpw:textures/gui/Chemer.png");
public GiuChema(Container inventorySlotsIn, BlinkingTileEntity tile) {
super(inventorySlotsIn);
// TODO Auto-generated constructor stub
this.tile = tile;
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
mc.renderEngine.bindTexture(F_GUI);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);//Menu
}
package com.Savage.redpw.gui;
import com.Savage.redpw.BlinkingTileEntity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ChemaConteiner extends Container
{
public ChemaConteiner(IInventory playerInv, BlinkingTileEntity barrel) {
int i = -18;
int j;
int k;
addSlotToContainer(new Slot(barrel.inventory, 1, 8, 61));
addSlotToContainer(new Slot(barrel.inventory, 2, 80, 33));//Инвентарь, id слота, X, Y
for (j = 0; j < 3; ++j){
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(new Slot(playerInv, k + j * 9 + 9, 8 + k * 18, 102 + j * 18 + i));//Слоты инвентаря
}
}
for (j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 160 + i));//Слоты инвентаря (нижния полоска)
}
//
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
return true;
}
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = null;
Slot slot = (Slot)this.inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index < 27) {
if (!this.mergeItemStack(itemstack1, 27, this.inventorySlots.size(), true)) {
return null;
}
}
else if(!this.mergeItemStack(itemstack1, 0, 27, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack)null);
}
else {
slot.onSlotChanged();
}
}
return itemstack;
}
}
package com.Savage.redpw;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
public class BlinkingTileEntity extends TileEntity implements ITickable
{
public InventoryBasic inventory;
public BlinkingTileEntity()
{
inventory = new InventoryBasic("Namer", true, 15);
}
@Override
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
NBTTagList list = new NBTTagList();
for(int i = 0; i < inventory.getSizeInventory(); i++)
{
if(inventory.getStackInSlot(i) != null)
{
NBTTagCompound component = new NBTTagCompound();
component.setByte("Slot", (byte)i);
inventory.getStackInSlot(i).writeToNBT(component);
list.appendTag(component);
}
}
compound.setTag("ItemStaks", list);
}
@Override
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList ls = compound.getTagList("ItemStaks", 10);
this.inventory = new InventoryBasic("Namer", false, 15);
for(int i = 0; i < ls.tagCount(); i++)
{
NBTTagCompound tag = ls.getCompoundTagAt(i);
byte b = tag.getByte("Slot");
if(b >= 0 && b < inventory.getSizeInventory())
{
inventory.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag));
}
}
}
@Override
public void update()
{
}
playerIn.openGui(Main.INSTANCE, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
0 - ID из GuiHundler
Main.INSTANCE -
//В главный клас (у меня это Main)
@Instance(MODID)
public static Main INSTANCE;
playerIn это EntityPlayer
Jack_Savage написал(а):[img=250x250]http://i.imgur.com/forcJsL.png[/img]
Вам нужно создать GuiHundler
Код:package com.Savage.redpw.gui; import com.Savage.redpw.BlinkingTileEntity; import com.Savage.redpw.Main; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHundler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch(ID) { case 0: return new ChemaConteiner(player.inventory, (BlinkingTileEntity) world.getTileEntity(new BlockPos(x, y, z))); default: return null; } } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch(ID) { case 0: return new GiuChema(new ChemaConteiner(player.inventory, (BlinkingTileEntity) world.getTileEntity(new BlockPos(x, y, z))), (BlinkingTileEntity) world.getTileEntity(new BlockPos(x, y, z))); default: return null; } } }
Потом сам gui аля картинка сзади и тд...
Код:package com.Savage.redpw.gui; import com.Savage.redpw.BlinkingTileEntity; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class GiuChema extends GuiContainer{ public BlinkingTileEntity tile; public static final ResourceLocation F_GUI = new ResourceLocation("redpw:textures/gui/Chemer.png"); public GiuChema(Container inventorySlotsIn, BlinkingTileEntity tile) { super(inventorySlotsIn); // TODO Auto-generated constructor stub this.tile = tile; } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { mc.renderEngine.bindTexture(F_GUI); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, ySize);//Menu }
И создать сам класс со слотами:
Код:package com.Savage.redpw.gui; import com.Savage.redpw.BlinkingTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ChemaConteiner extends Container { public ChemaConteiner(IInventory playerInv, BlinkingTileEntity barrel) { int i = -18; int j; int k; addSlotToContainer(new Slot(barrel.inventory, 1, 8, 61)); addSlotToContainer(new Slot(barrel.inventory, 2, 80, 33));//Инвентарь, id слота, X, Y for (j = 0; j < 3; ++j){ for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(playerInv, k + j * 9 + 9, 8 + k * 18, 102 + j * 18 + i));//Слоты инвентаря } } for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 160 + i));//Слоты инвентаря (нижния полоска) } // } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < 27) { if (!this.mergeItemStack(itemstack1, 27, this.inventorySlots.size(), true)) { return null; } } else if(!this.mergeItemStack(itemstack1, 0, 27, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } } return itemstack; } }
И в TileEntity засунуть:
Код:package com.Savage.redpw; import net.minecraft.client.Minecraft; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ITickable; public class BlinkingTileEntity extends TileEntity implements ITickable { public InventoryBasic inventory; public BlinkingTileEntity() { inventory = new InventoryBasic("Namer", true, 15); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList list = new NBTTagList(); for(int i = 0; i < inventory.getSizeInventory(); i++) { if(inventory.getStackInSlot(i) != null) { NBTTagCompound component = new NBTTagCompound(); component.setByte("Slot", (byte)i); inventory.getStackInSlot(i).writeToNBT(component); list.appendTag(component); } } compound.setTag("ItemStaks", list); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList ls = compound.getTagList("ItemStaks", 10); this.inventory = new InventoryBasic("Namer", false, 15); for(int i = 0; i < ls.tagCount(); i++) { NBTTagCompound tag = ls.getCompoundTagAt(i); byte b = tag.getByte("Slot"); if(b >= 0 && b < inventory.getSizeInventory()) { inventory.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag)); } } } @Override public void update() { }
Ну как то так...
Открывается вот так:
Код:playerIn.openGui(Main.INSTANCE, 0, worldIn, pos.getX(), pos.getY(), pos.getZ()); 0 - ID из GuiHundler Main.INSTANCE - //В главный клас (у меня это Main) @Instance(MODID) public static Main INSTANCE; playerIn это EntityPlayer
На счёт этогоvites написал(а):Я кидал, переделовал но нечего не смог, не могу зарегистрировать печку или там тайлы!Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
playerIn.openGui(Main.INSTANCE, 0, worldIn, pos.getX(), pos.getY(), pos.getZ());
0 - ID из GuiHundler
Main.INSTANCE -
//В главный клас (у меня это Main)
@Instance(MODID)
public static Main INSTANCE;
playerIn это EntityPlayer
Я не понял как зарегестрировать его!Jack_Savage написал(а):[img=250x500]http://i.imgur.com/GEhJ9w3.png[/img]
Вот в этих "папках" можно найти.
Там стандартный код майна как я понимаю
GreenBudgie написал(а):Мой тебе совет: сначала сделай простой мод, добавляющий хотя бы блок, а потом уже переходи к более сложным. Печка - никак не для новичка. И еще нужно знать джаву не на базовом уровне, а на более углубленном.