Jump to content

zlappedx3

Members
  • Posts

    157
  • Joined

  • Last visited

Everything posted by zlappedx3

  1. ItemStack slot1 = new ItemStack(Items.books); GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int k = (this.width - 176) / 2; int l = (this.height - 166 - 50) / 2; GL11.glPushMatrix(); GL11.glColor4f(10.0f, 200.0f, 10.0f, 1.0f); this.mc.renderEngine.bindTexture(new ResourceLocation("textures/atlas/items.png")); this.drawTexturedModelRectFromIcon(guiX, guiY - 35, slot1.getIconIndex(), 16, 16); GL11.glPopMatrix(); GL11.glPopMatrix(); if change item for block. ItemStack slot1 = new ItemStack(Item.getItemFromBlock(Blocks.stone)); GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int k = (this.width - 176) / 2; int l = (this.height - 166 - 50) / 2; GL11.glPushMatrix(); GL11.glColor4f(10.0f, 200.0f, 10.0f, 1.0f); this.mc.renderEngine.bindTexture(new ResourceLocation("textures/atlas/items.png")); this.drawTexturedModelRectFromIcon(guiX, guiY - 35, slot1.getIconIndex(), 16, 16); GL11.glPopMatrix(); GL11.glPopMatrix(); will can't show icon of block. i need show icon of block in gui screen.
  2. Request permission to post it this is not about java. Micosava hua kuy.
  3. I'm not good at English but will try explain you for understand. this is entity. public class EntityMerchant extends EntityMob { public List<Integer> Position = new ArrayList<Integer>(); public EntityMerchant(World par1World) { super(par1World); } @Override public void readEntityFromNBT(NBTTagCompound p_70037_1_){ super.readEntityFromNBT(p_70037_1_); NBTTagList tagList = p_70037_1_.getTagList("iPosition", Constants.NBT.TAG_COMPOUND); for(int i = 0; i < tagList.tagCount(); i++){ NBTTagCompound tag = tagList.getCompoundTagAt(i); int x = tag.getInteger("Position"); Position.add(i, x); } } @Override public void writeEntityToNBT(NBTTagCompound p_70014_1_){ super.writeEntityToNBT(p_70014_1_); NBTTagList tagList = new NBTTagList(); for(int i = 0; i < Position.size(); i++){ int x = Position.get(i); NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Position", x); tagList.appendTag(tag); } p_70014_1_.setTag("iPosition", tagList); } @Override public IEntityLivingData onSpawnWithEgg(IEntityLivingData data){ data = super.onSpawnWithEgg(data); return data; } public boolean isAIEnabled(){ return true; } protected boolean canDespawn(){ return false; } @Override public boolean interact(EntityPlayer player){ if(this.worldObj.isRemote) player.openGui(Moba.Instance, 1, this.worldObj, 0, this.getEntityId(), 0); return super.interact(player); } } this is guihandler. public class GuiHandler implements IGuiHandler{ @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ if(ID == 1){ EntityMerchant entity = (EntityMerchant)world.getEntityByID(y); if(x == 0 && entity!=null && z == 0){ return new GuiMerchant(entity); } } return null; } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 1){ EntityMerchant entity = (EntityMerchant)world.getEntityByID(y); if(x == 0 && entity!=null && z == 0){ return new ContainerMerchant(entity); } } return null; } } this is gui. @SideOnly(Side.CLIENT) public class GuiMerchant extends GuiContainer{ private EntityMerchant entityMerchant; public GuiMerchant(EntityMerchant tileEntity){ super(new ContainerMerchant(tileEntity)); this.entityMerchant = tileEntity; } @Override protected void drawGuiContainerForegroundLayer(int par1, int par2){ this.fontRendererObj.drawString("" + this.entityMerchant.Position.get(0), this.xSize /2 - 10, this.ySize /2 - 95, 0x000000); } @Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(new ResourceLocation("onermod:" + "textures/gui/shop_merchant.png")); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l - 20, 0, 0 , this.xSize + 70, this.ySize + 30); } @Override public void initGui(){ super.initGui(); } @Override protected void actionPerformed(GuiButton button){ switch(button.id){ case 0: } super.actionPerformed(button); } } and this is container public class ContainerMerchant extends Container{ private EntityMerchant tileChestShop; public ContainerMerchant(EntityMerchant tileChestShop){ this.tileChestShop = tileChestShop; } @Override public boolean canInteractWith(EntityPlayer player){ return true; } } Lua from I right click EntityMerchant for Open gui. but this.entityMerchant.Position.get(0) can't use in gui client @Override protected void drawGuiContainerForegroundLayer(int par1, int par2){ this.fontRendererObj.drawString("" + this.entityMerchant.Position.get(0), this.xSize /2 - 10, this.ySize /2 - 95, 0x000000); } I hope you understand this.
  4. I think you know, but pretend idiot.
  5. OK now i can do it. but now have new problem. i create List<Integer> in entity. public List<Integer> Position = new ArrayList<Integer>(); and i will use open gui by this. player.openGui(Main.Instance, 1, this.worldObj, 0, this.getEntityId(), 0); next i will use gui for open Position.get(0) @Override protected void drawGuiContainerForegroundLayer(int par1, int par2){ this.fontRendererObj.drawString("" + entityMerchant.Position.get(0), this.xSize /2 - 10, this.ySize /2 - 95, 0x000000); } but it error. this it GuiHandler. @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ if(ID == 0){ Entity entity = world.getEntityByID(y); if(x == 0 && entity!=null && z == 0){ return new GuiMerchant((EntityMerchant)entity); } } } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == 0){ TileEntityChestShop tileChestShop = (TileEntityChestShop) world.getTileEntity(x, y, z); return new ContainerChestShop(player.inventory, tileChestShop); } }
  6. i need change tileentity to entity @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z){ if(ID == 0){ TileEntityChestShop tileEntityChestShop = (TileEntityChestShop) world.getTileEntity(x, y, z); return new GuiChestShop(player.inventory, tileEntityChestShop); } } how to do it ?
  7. Thank you but i come across this post http://www.minecraftforge.net/forum/index.php?topic=21500.0
  8. OK I bad english. Sorry I try to communicate you that -> 1 I need check block stone in world. 2 If world have stone, player can break block of mod. 3 If world not have stone, player can't break block of mod. One more question : this question i can't ask you. if possible, you should teach me English.
  9. I will check block stone in world. I need to check block stone, if block stone has this world block of mod will can break if block stone hasn't this world block of mod can't break. One more question: If i do mod finish. Where can I post mod of me ?
  10. I create new class name AIMoveHuman by this class is EntityAIWander. public class AIMoveHuman extends EntityAIBase { private EntitySoliderMelee entity; private int xPosition; private double yPosition; private int zPosition; private double speed; private static int n = 0; public AIMoveHuman(EntitySoliderMelee p_i1648_1_, double p_i1648_2_) { this.entity = p_i1648_1_; this.speed = p_i1648_2_; this.setMutexBits(1); } /** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { this.xPosition = this.entity.PositionX.get(n); this.yPosition = this.entity.posY; this.zPosition = this.entity.PositionZ.get(n); int a = this.n + 1; if(a != this.entity.PositionX.size()){ this.n++; } return true; } /** * Returns whether an in-progress EntityAIBase should continue executing */ public boolean continueExecuting() { return !this.entity.getNavigator().noPath(); } /** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed); } } it will move follow list in entity. I will try add EntityAINearestAttackableTarget, if i have a problem, i will comback this post.
  11. I use tryMoveToXYZ for give it move but it move just 7-10 block. i need it move around the world.
  12. Thank You Ernio, now i can do time by world.getTotalWorldTime() and give it spawn on time. I'll try it your way, if there is a problem i will come back comment this post if i do you puzzling, i'm sorry
  13. What do you mean by "no effect"? New one gets spawned? No new one? Please be a bit more specific ... Easy, if we placed this block, this block will spawn zombie all the time. but updateTick can't do it. if updateTick doesn't always fire. what is always fire.
  14. I want spawn entity on block always. @Override public void updateTick(World world, int x, int y, int z, Random random){ if (!world.isRemote){ EntityMob entity1 = new EntityZombie(world); entity1.setPosition(x + 0.5D, y+1, z + 0.5D); entity1.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword)); world.spawnEntityInWorld(entity1); } }
  15. it not have variable but i use tag.setString("5", "test"); by command and out in gui by mc.fontRenderer.drawString("" + tag.getString("5"), int, int, 0); Sorry if my English was not good.
  16. Posted ago, I post about time in world but now, I need Sync it, I can Sync IExtendedEntityProperties but i can't Sync WorldSavedData. You can do it ? public abstract class AbstractMessage<T extends AbstractMessage<T>> implements IMessage, IMessageHandler <T, IMessage> { protected abstract void read(PacketBuffer buffer) throws IOException; protected abstract void write(PacketBuffer buffer) throws IOException; public abstract void process(World world, Side side); protected boolean isValidOnSide(Side side) { return true; } protected boolean requiresMainThread() { return true; } @Override public void fromBytes(ByteBuf buffer) { try { read(new PacketBuffer(buffer)); } catch (IOException e) { throw Throwables.propagate(e); } } @Override public void toBytes(ByteBuf buffer) { try { write(new PacketBuffer(buffer)); } catch (IOException e) { throw Throwables.propagate(e); } } @Override public final IMessage onMessage(T msg, MessageContext ctx) { if (!msg.isValidOnSide(ctx.side)) { throw new RuntimeException("Invalid side " + ctx.side.name() + " for " + msg.getClass().getSimpleName()); } else if (msg.requiresMainThread()) { checkThreadAndEnqueue(msg, ctx); } else { msg.process(main.proxy.getPlayerEntity(ctx).worldObj, ctx.side); } return null; } private static final <T extends AbstractMessage<T>> void checkThreadAndEnqueue(final AbstractMessage<T> msg, final MessageContext ctx) { IThreadListener thread = main.proxy.getThreadFromContext(ctx); thread.addScheduledTask(new Runnable() { public void run() { msg.process(main.proxy.getPlayerEntity(ctx).worldObj, ctx.side); } }); } public static abstract class AbstractClientMessage<T extends AbstractMessage<T>> extends AbstractMessage<T> { @Override protected final boolean isValidOnSide(Side side) { return side.isClient(); } } } public class SyncWorldPropsMessage extends AbstractClientMessage<SyncWorldPropsMessage> { private NBTTagCompound data; public SyncWorldPropsMessage() {} public SyncWorldPropsMessage(World world) { data = new NBTTagCompound(); WorldData.forWorld(world).writeToNBT(data); } @Override protected void read(PacketBuffer buffer) throws IOException { data = buffer.readNBTTagCompoundFromBuffer(); } @Override protected void write(PacketBuffer buffer) throws IOException { buffer.writeNBTTagCompoundToBuffer(data); } @Override public void process(World world, Side side) { WorldData.forWorld(world).readFromNBT(data); } } public class WorldData extends WorldSavedData { final static String key = References.MODID; private NBTTagCompound data = new NBTTagCompound(); public WorldData(String tagName) { super(tagName); } public static WorldData forWorld(World world) { MapStorage storage = world.perWorldStorage; WorldData result = (WorldData)storage.loadData(WorldData.class, key); if (result == null) { result = new WorldData(key); storage.setData(key, result); } return result; } @Override public void readFromNBT(NBTTagCompound compound) { data = compound.getCompoundTag(key); } @Override public void writeToNBT(NBTTagCompound compound) { compound.setTag(key, data); } public NBTTagCompound getData() { return data; } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.