-
Posts
878 -
Joined
-
Last visited
Everything posted by Elix_x
-
Sorry for repeating, but have you tried what i said you above??? Because it MUST work... If you're too lazy, here's modified centered code for gui: public class GuiLexicon extends GuiScreen { int guiWidth = 192; int guiHeight = 256; int guiLeft = 0; int guiTop = 0; public GuiLexicon() { guiLeft = (width - guiWidth) / 2; guiTop = (height - guiHeight) / 2; } static int GUI_ID = 30; @Override public void drawScreen(int mouseX, int mouseY, float par3) { super.drawScreen(mouseX, mouseY, par3); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(SignificantAdvancements.MODID, "textures/guis/lexiconBackground.png")); this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, guiWidth, guiHeight); int stringWidth = this.fontRendererObj.getStringWidth(I18n.format("lexiconOfKnowledge.lang")); this.fontRendererObj.drawString(I18n.format("lexiconOfKnowledge.lang"), guiWidth - stringWidth, 50, 0x00FFFF, true); } } Ps: this is also multi language friendly!!! And also, func_146110_a is static and in Gui.class
-
[1.7.10] [SOLVED] Get all blocks in virtual pyramid.
Elix_x replied to Elix_x's topic in Modder Support
As i said, no error message: mc goes not responding and after few minutes closes without leaving anything in cosole (event no sound resources shutting down!) -
Hi there and thanks for looking in this thread... My problem is: i'm trying to get all entities and blocks in world within virtual rotated pyramid (similar to AABB, but pyramidal form and is rotated), but it goes not respoding and crashes without leaving any message in console. Here's code that i'm using: public class PositionnedRotatedRangedVec3 { private World worldObj; private double posX; private double posY; private double posZ; private float rotYaw; private float rotPitch; private float rotR; private double range; public PositionnedRotatedRangedVec3(World worldObj, double posX, double posY, double posZ, float rotationYaw, float rotationPitch, float rotR, double range) { setData(worldObj, posX, posY, posZ, rotationYaw, rotationPitch, rotR, range); } public void setData(World worldObj, double posX, double posY, double posZ, float rotationYaw, float rotationPitch, float rotR, double range){ this.worldObj = worldObj; this.posX = posX; this.posY = posY; this.posZ = posZ; this.rotYaw = rotationYaw; this.rotPitch = rotationPitch; this.rotR = rotR; this.range = range; /*Vec3 vec = Vec3Utils.getLookVec(rotationYaw + rotR, rotationPitch + rotR); adjustX = vec.xCoord; adjustY = vec.yCoord; adjustZ = vec.zCoord;*/ } public Set<BlockPos> getAffectedBlocks(){ Set<BlockPos> blocks = new HashSet<BlockPos>(); Vec3[] vecs = new Vec3[]{Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ)}; boolean arrived = false; while(!arrived){ double minX = posX; double minY = posY; double minZ = posZ; double maxX = posX; double maxY = posY; double maxZ = posZ; for(int i = 0; i < 5; i++){ Vec3 vec = vecs[i]; if(i == 0){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw, rotPitch); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 1){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw + rotR, rotPitch + rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 2){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw - rotR, rotPitch + rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 3){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw + rotR, rotPitch - rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 4){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw - rotR, rotPitch - rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } minX = Math.min(minX, vec.xCoord); minY = Math.min(minY, vec.yCoord); minZ = Math.min(minZ, vec.zCoord); maxX = Math.max(maxX, vec.xCoord); maxY = Math.max(maxY, vec.yCoord); maxZ = Math.max(maxZ, vec.zCoord); vecs[i] = vec; } // AxisAlignedBB box = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); for(int i = (int) minX; i <= maxX; i++){ for(int j = (int) minY; j <= maxY; j++){ for(int k = (int) minZ; k <= maxZ; k++){ blocks.add(new BlockPos(i, j, k)); } } } if(vecs[0].distanceTo(Vec3.createVectorHelper(posX, posY, posZ)) >= range){ arrived = true; break; } } return blocks; } public Set<Entity> getAffectedEntities(){ Set<Entity> entities = new HashSet<Entity>(); Vec3[] vecs = new Vec3[]{Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ), Vec3.createVectorHelper(posX, posY, posZ)}; boolean arrived = false; while(!arrived){ double minX = posX; double minY = posY; double minZ = posZ; double maxX = posX; double maxY = posY; double maxZ = posZ; for(int i = 0; i < 5; i++){ Vec3 vec = vecs[i]; if(i == 0){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw, rotPitch); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 1){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw + rotR, rotPitch + rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 2){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw - rotR, rotPitch + rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 3){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw + rotR, rotPitch - rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } if(i == 4){ Vec3 vec2 = Vec3Utils.getLookVec(rotYaw - rotR, rotPitch - rotR); vec = vec.addVector(vec2.xCoord, vec2.yCoord, vec2.zCoord); } minX = Math.min(minX, vec.xCoord); minY = Math.min(minY, vec.yCoord); minZ = Math.min(minZ, vec.zCoord); maxX = Math.max(maxX, vec.xCoord); maxY = Math.max(maxY, vec.yCoord); maxZ = Math.max(maxZ, vec.zCoord); vecs[i] = vec; } AxisAlignedBB box = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); entities.addAll(worldObj.getEntitiesWithinAABB(Entity.class, box)); } return entities; } } Let me explain here: posX, Y, Z are start point of pyramid. Rot yaw and pitch are rotations of pyramid. Rot r is angle of rotations of borders relative to central axis. And finally range is height of pyramid... BlockPos is class, that i created to store 3 ints of position. It "crashes" when enters one of 2 methods, to scan for blocks/entities... So my questions are: Is there already existing methods to do what i want, and if not - what should i use or how should i improve mine... If it's too hard with pyramids, will it be easier with rotated BB? Thanks for help, and again: if you have any questions, need some more code... - Just ask! Ps: i resolved problem by adding loop break (because i forgot it , that's why it went not responding and never stopped ) and changing some more code to make it pyramid. Here's what i obtained with height 100, border degree 30:
-
[1.7.10] Questions about Bounding boxes and World renderers
Elix_x replied to Elix_x's topic in Modder Support
But only 16 blocks of height? -
Passing NBT item data to NBT tileEntity data?
Elix_x replied to Alphafox_13's topic in Modder Support
To do this you need to create own item block for this block, to override on item use, to pass nbt to te... -
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
Does writing to nbt happens on both sides (it includes checking if method is called on both sides!)? Be sure to check that. -
As i said, to center your WHOLE gui, and without worriing to center EACH element, in gui constructor add this, and then use guiTop and guiLeft as offset depart point...: this.guiLeft = (this.width - this.xSize) / 2; this.guiTop = (this.height - this.ySize) / 2; What happens here, i may represent as: this.guiLeft = this.width / 2 - this.xSize / 2 What this does: finds middle of screen (width/2) and substracts half of size of gui (xSize/2), in result middle of gui is middle of screen. But using laws of maths, we can convert this formula to this.guiLeft = (this.width - this.xSize) / 2 And all that is left to do: each element draw relative to guiLeft and guiTop. Example of drawing background: this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, guiWidth, guiHeight); Example of drawing element: this.drawTexturedModalRect(guiLeft + 123, guiTop + 59, 0, 0, 16, 16); PS: like that you don't need to worry about scaled resolution stuff. BTW: if you haven't access to gui constructor, do this in gui init event.
-
(facepalm) to all above Just look in vanilla code... If you are too lazy: this.guiLeft = (this.width - this.xSize) / 2; this.guiTop = (this.height - this.ySize) / 2;
-
For client, there's I18n. Use format() with unlocalized name...
-
Facepalm... typo mistake... And i was not using list, beacause i'm a litle bit confused how to use it... Well i'll try how ever... EDIT: well, i'm still confused about them... EDIT 2: it was typo mistake... again...
-
I mean all lists become empty, booleans defaults to false and ints to 0. This includes both slient&server!!! (why???) IEEP: public class ExtendedBreathingProperties implements IExtendedEntityProperties{ private boolean breathing; private Set<BreathEffect> effects = new HashSet<BreathEffect>(); public ExtendedBreathingProperties() { setBreathing(false); } public boolean isBreathing() { return breathing; } public void setBreathing(boolean breathing) { this.breathing = breathing; } public void addEffect(BreathEffect effect){ effects.add(effect); } public void removeEffect(BreathEffect effect){ effects.remove(effects); } public Set<BreathEffect> getEffects(){ return effects; } @Override public void saveNBTData(NBTTagCompound nbt) { NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound es = new NBTTagCompound(); int a = 0; for(BreathEffect effect : effects){ es.setTag("eN" + a, effect.writeToNBT(new NBTTagCompound())); a++; } es.setInteger("lenght", a); tag.setTag("effects", es); tag.setBoolean("breathing", breathing); nbt.setTag("breathing", tag); BreathEffectManager.logger.info("Saving propreties data to nbt: " + tag + " on " + FMLCommonHandler.instance().getSide()); } @Override public void loadNBTData(NBTTagCompound nbt) { NBTTagCompound tag = nbt.getCompoundTag("breathing"); NBTTagCompound es = tag.getCompoundTag("effects"); BreathEffectManager.logger.info("Loading propreties data from nbt: " + tag + " on " + FMLCommonHandler.instance().getSide()); for(int a = 0; a < nbt.getInteger("lenght"); a++){ try { effects.add(BreathEffect.createFromNBT(es.getCompoundTag("eN" + a))); } catch (Exception e) { BreathEffectManager.logger.warn("Caught exception while restoring effect: ", e); } } breathing = tag.getBoolean("breathing"); } @Override public void init(Entity entity, World world) { BreathEffectManager.logger.info("Initializing proprieties on " + FMLCommonHandler.instance().getSide()); } }
-
I understand that first one is server and second one is client, but why then data is nullified on both sides after client loading???
-
Hello, so my problem is this: Entity properties registered twice, initialized twice, but loaded (readFromNbt) only once, what results in nulliffing of data; This happens like this (Checked via console); -register (EntityConstruct) -init (Propery.init) -load (Propery.readFromNbt) -register -init All the code that you may want here is EntityConstructEvent, but if you need something else - just ask: public class OnEntityConstructEvent { public OnEntityConstructEvent() { } @SubscribeEvent public void construct(EntityConstructing event){ if(event.entity instanceof EntityPlayer){ if(event.entity.getExtendedProperties("breathing") == null){ System.out.println("Registered new propreties on " + FMLCommonHandler.instance().getSide() + " old propreties: " + event.entity.getExtendedProperties("breathing")); event.entity.registerExtendedProperties("breathing", new ExtendedBreathingProperties()); } } } } Thanks for help, and again: if you need something(code/console/...) - just ask!
-
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
Try manipulating directly: itemstack.stackTagCompound.set... -
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
Basically, item nbt changes must happen on server. And uuid can be called any where (in this case server, because nbt must be changed on server) -
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
UUID of player is the same on all worlds (for not pirate mc profiles)... so using it you can get player in any world... -
[1.7.10][SOLVED] Syncing a lot of data between client and server...
Elix_x replied to Elix_x's topic in Modder Support
Thank you very much for help. I think finally i'll use split if models will be too big. And also, do you now answer to this question? -
[1.7.10] Questions about Bounding boxes and World renderers
Elix_x replied to Elix_x's topic in Modder Support
Okay. i looked in world renderer code and there's 3 for loops for blocks, but vars are messed up. Can anybody show me this littlest and biggest x,y,z pos in it? Please??? -
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
You can get uuid from playerEntity and playerEntity from uuid also you can get playerName from playerEntity. Easy? -
[1.7.10][SOLVED] Syncing a lot of data between client and server...
Elix_x replied to Elix_x's topic in Modder Support
And do you think that separating bytes in multiple packets and sending like that, will it be easier than creating new handler? -
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
No, it is implemented for all versions, if you change your name it will change everywhere. That's why you need to use uuid. -
[1.7.10] Need my item to get the players display name
Elix_x replied to HappyKiller1O1's topic in Modder Support
An also using display name is bad idea, use uuid instead (ps, you can get players name from uuid!). Because of reasons of name changes... -
[1.7.10][SOLVED] Syncing a lot of data between client and server...
Elix_x replied to Elix_x's topic in Modder Support
Wait. Do you now what is max size of forge packet??? -
[1.7.10][SOLVED] Syncing a lot of data between client and server...
Elix_x replied to Elix_x's topic in Modder Support
If this is what you are asking then above should be correct. I could quote Diesieben if i could find it. So from client to server you need to split and put it back together on your own. So for c-s i need to write my own, and s-c forge has one... That's better!