Jump to content

artman41

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by artman41

  1. Hi, I'm mainly looking for a bit of direction because I'm sorta stumped. Essentially, I'm trying to replace the renderer for the minecraft:nether_portal block without affecting any of the generation or utility code surrounding it. So far, I've registered a `BlockEntityRenderer` bound to a `BlockEntityType` which is built from `Blocks.NETHER_PORTAL` but this doesn't seem to work (or at least the `BlockEntityRenderer.render` function isn't being hit) Has anyone got a guide or some suggestions that could point me in the right direction?
  2. If you're going to do this, I would suggest just removing client side configs entirely and depend solely upon server side configs since singleplayer runs it's own server, causing two sets of configs to be necessary.
  3. I've been working on homing arrows for ProjectE and I have the homing part working. However, after finding the entity to attack, the arrow doesn't change it's yaw or pitch and I have no clue about how to work this out. Does anybody know how I'd go about this? The class of code is below: package moze_intel.projecte.gameObjs.entity; import moze_intel.projecte.utils.WorldHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import java.util.List; public class EntityHomingArrow extends EntityArrow { EntityLiving target; World world; private void init(World world) { this.world = world; } public EntityHomingArrow(World world) { super(world); init(world); } public EntityHomingArrow(World world, EntityLivingBase par2, float par3) { super(world, par2, par3); init(world); } @Override public void onUpdate() { //TODO Create proper custom arrow. This one is duplicating because of the super call for onUpdate(); super.onUpdate(); AxisAlignedBB box = this.boundingBox; if (target == null && !WorldHelper.isArrowInGround(this)) { System.out.println("TARGET == NULL"); AxisAlignedBB bBox = box.expand(8, 8, ; List<EntityLiving> list = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, bBox); double distance = 100000; double disToEnt1 = 1000; for (EntityLiving entity : list) { double toIt = distanceTo(entity); double disToEnt2 = distanceTo(entity); if(disToEnt2 < disToEnt1){ disToEnt1 = disToEnt2; target = entity; } // if (distance > toIt) // { // distance = toIt; // target = entity; // } } if (target == null) { return; } double xyz[] = checkDistance(target, this.posX, this.posY, this.posZ); double x = xyz[0]; double y = xyz[1]; double z = xyz[2]; this.setThrowableHeading(x, y, z, 2.0F, 0.0F); } else if (!WorldHelper.isArrowInGround(this)) { System.out.println("TARGET != NULL"); if (target.getHealth() == 0) { target = null; return; } world.spawnParticle("flame", box.maxX, box.maxY, box.maxZ, 0.0D, 0.0D, 0.0D); this.setPositionAndRotation(target.posX, target.posY, target.posZ, target.rotationYaw, target.rotationPitch); double xyz[] = checkDistance(target, this.posX, this.posY, this.posZ); double x = xyz[0]; double y = xyz[1]; double z = xyz[2]; this.setThrowableHeading(x, y, z, 2.0F, 0.0F); } } private double distanceTo(EntityLiving entity) { double [] ds = new double [] { this.posX - entity.posX, this.posY - entity.posY, this.posZ - entity.posZ }; double d = 0; for (int i = 0; i < 3; i++) d += ds[i] * ds[i]; return Math.sqrt(d); } private double[] checkDistance(EntityLiving entity, double x, double y, double z){ double rX, rY, rZ; System.out.println("LOCATION OF ENTITY: " + entity.posX + ", " + entity.posY + ", " + entity.posZ); rX = x; rY = y; rZ = z; if(entity.posX != x){ if(entity.posX > x){ rX =+ entity.posX; } else{ rX--; } } if(entity.posY != y){ if(entity.posY > y){ rY =+ entity.posY; } } if(entity.posZ != z){ if(entity.posZ > z){ rZ =+ entity.posZ; } else{ rZ--; } } double rValues[] = {rX, rY, rZ}; for(int i = 0; i < rValues.length; i++){ if(i == 0){System.out.println("x " + rValues[i]);} if(i == 1){System.out.println("y " + rValues[i]);} if(i == 2){System.out.println("z " + rValues[i]);} } return rValues; } }
  4. Check Line 26 of your VillagerKing file. You're missing a ; as seen by
  5. I'm adding a button to allow the search bar in ProjectE to interface with the NEI search bar. Here's the code: package moze_intel.projecte.gameObjs.gui; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; import moze_intel.projecte.PECore; import moze_intel.projecte.gameObjs.container.TransmuteContainer; import moze_intel.projecte.gameObjs.tiles.TransmuteTile; import moze_intel.projecte.network.PacketHandler; import moze_intel.projecte.network.packets.ClientSyncTabletLinkPKT; import moze_intel.projecte.network.packets.SearchUpdatePKT; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import org.lwjgl.opengl.GL11; public class GUITransmute extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation(PECore.MODID.toLowerCase(), "textures/gui/transmute.png"); private TransmuteTile tile; private GuiTextField textBoxFilter; private GuiButton neiLink; int xLocation; int yLocation; int neiLinkID = 1; int neiLinkWidth = 15; int neiLinkHeight = 10; private static int isLinkEnabled = 0; public GUITransmute(InventoryPlayer invPlayer, TransmuteTile tile) { super(new TransmuteContainer(invPlayer, tile)); this.tile = tile; this.xSize = 228; this.ySize = 196; } @Override public void initGui() { tile.setPlayer(Minecraft.getMinecraft().thePlayer); super.initGui(); this.xLocation = (this.width - this.xSize) / 2; this.yLocation = (this.height - this.ySize) / 2; this.textBoxFilter = new GuiTextField(this.fontRendererObj, this.xLocation + 88, this.yLocation + 8, 45, 10); this.textBoxFilter.setText(tile.filter); drawButton(true, isLinkEnabled); } protected void actionPerformed(GuiButton guiButton) { super.actionPerformed(guiButton); switch(guiButton.id) { case 1: System.out.println("Button clicked"); if(this.isLinkEnabled == 0){ System.out.println("Disabled"); PacketHandler.sendToServer(new ClientSyncTabletLinkPKT(1)); drawButton(false, isLinkEnabled); } else{ System.out.println("Enabled"); PacketHandler.sendToServer(new ClientSyncTabletLinkPKT(0)); drawButton(false, isLinkEnabled); } break; } } public static int getLinkEnabled(){ return isLinkEnabled; } public static void setLinkEnabled(int i){ isLinkEnabled = i; } private void drawButton(boolean firstRun, int enabled){ if(firstRun){ this.buttonList.clear(); //id, x, y, width, height, text this.buttonList.add(new GuiButton(neiLinkID, this.textBoxFilter.xPosition, (this.textBoxFilter.yPosition + 10) + 2, neiLinkWidth, neiLinkHeight, "A")); this.isLinkEnabled = 0; }else{ try{ switch(enabled){ case 0: this.neiLink.displayString = "A"; break; case 1: this.neiLink.displayString = "B"; break; } } catch(NullPointerException e){ e.printStackTrace(); } } } @Override public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); this.textBoxFilter.drawTextBox(); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); } @Override protected void drawGuiContainerForegroundLayer(int var1, int var2) { this.fontRendererObj.drawString("Transmutation", 6, 8, 4210752); String emc = String.format("EMC: %,d", (int) tile.getStoredEmc()); this.fontRendererObj.drawString(emc, 6, this.ySize - 94, 4210752); if (tile.learnFlag > 0) { this.fontRendererObj.drawString("L", 98, 30, 4210752); this.fontRendererObj.drawString("e", 99, 38, 4210752); this.fontRendererObj.drawString("a", 100, 46, 4210752); this.fontRendererObj.drawString("r", 101, 54, 4210752); this.fontRendererObj.drawString("n", 102, 62, 4210752); this.fontRendererObj.drawString("e", 103, 70, 4210752); this.fontRendererObj.drawString("d", 104, 78, 4210752); this.fontRendererObj.drawString("!", 107, 86, 4210752); tile.learnFlag--; } } @Override public void updateScreen() { super.updateScreen(); this.textBoxFilter.updateCursorCounter(); } @Override protected void keyTyped(char par1, int par2) { if (this.textBoxFilter.isFocused()) { this.textBoxFilter.textboxKeyTyped(par1, par2); String srch = this.textBoxFilter.getText().toLowerCase(); if (!tile.filter.equals(srch)) { PacketHandler.sendToServer(new SearchUpdatePKT(srch)); tile.filter = srch; tile.updateOutputs(); } } if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.getKeyCode() && !this.textBoxFilter.isFocused()) { this.mc.thePlayer.closeScreen(); } } @Override protected void mouseClicked(int x, int y, int mouseButton) { super.mouseClicked(x, y, mouseButton); int minX = textBoxFilter.xPosition; int minY = textBoxFilter.yPosition; int maxX = minX + textBoxFilter.width; int maxY = minY + textBoxFilter.height; if (mouseButton == 1 && x >= minX && x <= maxX && y <= maxY) { PacketHandler.sendToServer(new SearchUpdatePKT("")); tile.filter = ""; tile.updateOutputs(); this.textBoxFilter.setText(""); } this.textBoxFilter.mouseClicked(x, y, mouseButton); } @Override public void onGuiClosed() { super.onGuiClosed(); tile.learnFlag = 0; } }
  6. As said in the title, I'm getting a NullPointerException when I edit the guiButton.displayText. I'm doing this while the gui is open and I'm not sure of any other way of doing it. Any help? protected void actionPerformed(GuiButton guiButton) { super.actionPerformed(guiButton); switch(guiButton.id) { case 1: System.out.println("Button clicked"); if(this.isLinkEnabled == 0){ System.out.println("Disabled"); this.isLinkEnabled = 1; drawButton(false, isLinkEnabled); } else{ System.out.println("Enabled"); this.isLinkEnabled = 0; drawButton(false, isLinkEnabled); } break; } //Packet code here //PacketDispatcher.sendPacketToServer(packet); //send packet } private void drawButton(boolean firstRun, int enabled){ if(firstRun){ this.buttonList.clear(); //id, x, y, width, height, text this.buttonList.add(new GuiButton(neiLinkID, this.textBoxFilter.xPosition, (this.textBoxFilter.yPosition + 10) + 2, neiLinkWidth, neiLinkHeight, "A")); this.isLinkEnabled = 0; }else{ try{ switch(enabled){ case 0: this.neiLink.displayString = "A"; break; case 1: this.neiLink.displayString = "B"; break; } } catch(NullPointerException e){ e.printStackTrace(); } } }
  7. I'd still be in the floor about 7-8 blocks lower than I teleported to though
  8. Any help? I've been adding 10 to the newY value, but that causes unnecessary fall damage. here's the code: private static void teleportPlayer(EntityPlayerMP player){ int newX = (rand.nextInt(65536)-32768); int newY = 60; int newZ = (rand.nextInt(65536)-32768); boolean safe = safetyCheck(player.worldObj, newX, newY, newZ); while(!safe){ newY++; safe = safetyCheck(player.worldObj, newX, newY, newZ); //System.out.println("BlockExists: " + safe); } player.playerNetServerHandler.setPlayerLocation(newX, newY + 13, newZ, player.rotationYaw, player.rotationPitch); afterCheck(player, newX, newY, newZ); } --EDIT-- If you have the same problem as me, the code you need to use is player.setPositionAndUpdate(newX, newY, newZ);
  9. If you're going to be using models a lot, I would suggest adding Tabula by Ichun to your develpoment workspace. It's almost exactly the same as techne except that it's updated, the exported code works for 1.7 and there's some other features. It also runs in your mc client so there's no need to have another program open
  10. I'm trying to check to see if a block at some co-ords is equal to either air or to water. However, even if it is air, it still returns true. Any help please? I'm a bit confused. private static boolean doesBlockExist(int x, int y, int z){ if(Minecraft.getMinecraft().theWorld.getBlock(x, y, z) == Blocks.air){ System.out.println("Block: " + Minecraft.getMinecraft().theWorld.getBlock(x, y, z)); return false; }else if(Minecraft.getMinecraft().theWorld.getBlock(x, y, z) == Blocks.water){ System.out.println("Block: " + Minecraft.getMinecraft().theWorld.getBlock(x, y, z)); return false; }else{ System.out.println("Block: " + Minecraft.getMinecraft().theWorld.getBlock(x, y, z)); return true; } } -- EDIT -- I have fixed the code thanks! For anyone who is having the same problems, you need to use the server side world, which you can get from the EntityPlayerMP via player.worldObj
  11. What he means is you need to learn simple coding in general. For example, when reading the pastebin Diesieben made, I noticed that your public method didn't have a closing brace (}) you opened two braces and only close one. You need to learn how to use simple code like diesie said before tackling things like this. If I were you, I would try a simpler language or learn how IF, AND and NOT functions work and watch a tutorial about how to use them. Learn the language and the general rules about them. 9 times out of 10, indentation WILL help identify a problem. To identify a problem, follow the code; it's a piece of text that should do what you want when you read it in your head and indentation will help you read it. Copying and Pasting is also not learning how to code. It's cheating and you'll learn nothing that way. Try to achieve somethings on your own. For example, create a java app that calls a method that checks if a boolean is true or false and then outputs something to the console, WITHOUT googling for help and copying. Training yourself with exercises like this is what will help you learn how to code.
  12. If you're looking to get an item from right-clicking on bushes, check the code for Tinkers' Construct: https://github.com/SlimeKnights/TinkersConstruct/blob/master/src/main/java/tconstruct/world/blocks/OreberryBush.java <-- is a bush similar to yours from the sounds of it https://github.com/SlimeKnights/TinkersConstruct/tree/master/src/main/java/tconstruct <-- the link to all the code
  13. I want to perform a method when the player levels up but I can't see a method I can override inside of EntityPlayer to do this, is there sn event I can hook into that will let me trigger a method when the player levels up?
  14. I want to add a button to the main menu and the pause menu. I've had a look at GuiIngameMenu, but I can't see from where it's adding the buttons from the buttonlist. I would also prefer to do this without overwriting the vanilla menu, if at all possible. Could anyone point me in the right direction?
  15. Yeah, just found that by backtracking through forge, thanks for the help though
  16. All I could find was code saying to first create a Logger object like so: final static Logger logger = Logger.getLogger(HelloExample.class); thing is, this method doesn't exist in either org.apache.logging.log4j.core.Logger or org.apache.logging.log4j.Logger any help? Please? -- EDIT -- Doesn't matter, worked out how to do it by backtracking through forge's logger
  17. Do you have any code I can look at to learn how to use a logger?
  18. when ever I use the system.out.println("Things here") code, It outputs [com.artman41.realtime.RealTime:changeTime:82]: [realtime] Changing world time to 20384... into the console instead of [realtime] Changing world time to 20384... any help?
  19. I'm having trouble changing the time server side on server tick. I don't know where to access the server version of world, but I can access the client side so I know my time change code is working. Any help? @SubscribeEvent public void onServerTick(TickEvent.ServerTickEvent event) { if(i == (20*60)){ try{ String time = sdf.format(cal.getTime()); String[] Time = time.split(":"); int hour = Integer.parseInt(Time[0]); System.out.println("[" + Reference.modID + "] " + hour); System.out.println(hour * 1000); long worldTime = hour * 1000; System.out.println("[" + Reference.modID + "] " + worldTime); if(!mc.theWorld.isRemote){ System.out.println("[" + Reference.modID + "] Changing world time..."); mc.theWorld.setWorldTime(worldTime); System.out.println("[" + Reference.modID + "] Time changed!"); } }catch(NullPointerException exception){ System.out.println("[" + Reference.modID + "] ERROR:" + exception); } i = 0; } System.out.println(i); i++; }
  20. My gui appears fine. However, only the top-left part of my Gui is drawn. In the code, I specify the correct width and height of the image, so I'm at a loss as to what is doing it. Here is the code: package com.artman41.pockets.gui; import org.lwjgl.opengl.GL11; import com.artman41.pockets.misc.Reference; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; public class Pocket1 extends GuiScreen{ ResourceLocation texture = new ResourceLocation(Reference.modID.toLowerCase(), "textures/gui/background.png"); public final int xSizeofTexture = 105, ySizeofTexture = 107; public Pocket1(EntityPlayer player){ } @Override public void drawScreen(int x, int y, float f){ drawDefaultBackground(); GL11.glColor4f(1f, 1f, 1f, 1f); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); int posX = (this.width - xSizeofTexture) / 2; int posY = (this.height - ySizeofTexture) / 2; drawTexturedModalRect(posX, posY, 0, 0, xSizeofTexture, ySizeofTexture); super.drawScreen(x, y, f); } @Override public boolean doesGuiPauseGame(){ return false; } } And here is the image:
  21. If I modify the NBT data inside the onCreated method, the game freezes since there is no data for the tooltip So I don't know where else to put it .-.
  22. How does this function work? I'm trying to use it to get a block via an unlocalized name I'm getting from the nbt data of an item. Currently, however, it doesn't really do anything public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4) { itemstack.stackTagCompound = new NBTTagCompound(); itemstack.stackTagCompound.setString("Block", Blocks.stone.getUnlocalizedName()); list.add("Magic Wand"); list.add(itemstack.stackTagCompound.getString("Block").substring(5)); } public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par2World.isRemote){ int minWX = (int)par3EntityPlayer.posX & ~0x0f; // throws away the bottom four bits, i.e. truncates to the next lowest multiple of 16, eg 32, 16, 0, -16, -32 etc int minWZ = (int)par3EntityPlayer.posZ & ~0x0f; int maxWX = minWX + 15; int maxWZ = minWZ + 15; Reference.fillChunk(minWX, minWZ, maxWX, maxWZ, par2World, par3EntityPlayer, Recipes.Stick2); } return par1ItemStack; } public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int x, int y, int z, int side, float hitX, float hitY, float hitZ){ if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { if (!par3World.isRemote) { par1ItemStack.stackTagCompound.setString("Block", par3World.getBlock(x, y, z).getUnlocalizedName()); return true; } return false; } Then this is the fillChunk function: public static void fillChunk(int minWX, int minWZ, int maxWX, int maxWZ, World par1World, EntityPlayer Player, ItemStack par1ItemStack){ for (int wx = minWX; wx <= maxWX; ++wx) { for (int wz = minWZ; wz <= maxWZ; ++wz) { // setblock (wx, playerYpos - 1, wz) par1World.setBlock(wx, (int)Player.posY -1, wz, Block.getBlockFromName(par1ItemStack.stackTagCompound.getString("Block").substring(5))); } }
×
×
  • Create New...

Important Information

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