American2050
Members-
Posts
553 -
Joined
Everything posted by American2050
-
That combination, will make the code on the torch to run and react. What I'm looking for is "onBlockActivated" on the Block class to react to the off-hand (And I mean, if something happened and I return true, the swing animation to take place on the off hand and not on main) But apparently that's not possible, at least no with the normal methods, as onBlockActivated get called only once.
-
Sorry, didn't know where to ask this, so hopefully someone can move it to the right section. I'm having a problem on the forum, and it's that each time I try to send a Message to another user, it says I have my inbox full. However, I only have 1 message there (Is that really the limitation) we can only have going conversations with only 1 user at a time? Well, hopefully someone can review this and fix it so we able to message members more "freely" Thanks a lot.
-
Try all lowercase? Can you also post the whole class, and where it's been called? Thanks.
-
[1.12.2] Rendering layered texture from IBakedModel
American2050 replied to BlackSun559's topic in Modder Support
Also followed that tutorial, but in my case I used as a guide the MBE5 block. Was more adequate to what I wanted to achieve. Check this post, lot of great answers that helped me, hopefully they help you too also. PS: What you actually want is only the top face of the block to adopt the texture, and not it as a whole? -
I believe the problem is that you passing the Category first, and the value you want as 2nd parameter. Isn't it the other way around? ConfigValues.showLog = configuration.getBoolean("showLog", CATEGORY_GENERAL, ConfigValues.showLog, "Shows info logs");
-
Well I noticed in this case, when I right click on a block and the server does nothing, then the block I have in my hand gets placed next to my block, when I right click with other conditions, like holding a panel (an item) that goes into my block, everything is working correctly. However, and as I'm doing like the Vanilla Furnace does and I check if world is client side, return true (100% the time) I notice that, when a block is placed, it doesn't plays the sound of a block been placed Vanilla doesn't worry about it, because a right click on a furnace will always open a gui, but that's not the case for my block. PS: That's what I was asking, I guess one case would be when I want something to happen on the block, but I don't want the player "swing" the hand? Isn't that one of the things that returning true client side in that method handles? it makes the player swing the hand, and maybe other stuff?
-
But if I do the conditions check, only server side, how do I know client side if the conditions check on server triggered some action or not so I can return same boolean both sides?
-
Few questions about the return for methods (Example: onBlockActivated) on the Block class. Should we always return the same boolean server and Client side? If no, what would be exceptions to this. Also. When we do need to return the same boolean both sides, what's the best way to do it, when some of our code should run only Server side? Example: onBlockActivated and under certain conditions the method will spawn items (Entities) on the world, thing that should happen only Server side. I do the conditions check on both sides, then I wrap my spawn entities on server side only and then outside this I return true?
-
[1.12.2] [SOLVED] GUI Width - What am I missing?
American2050 replied to American2050's topic in Modder Support
SOLVED: I moved protected int xSize = 256; protected int ySize = 220; into the constructor and fixed My bad. -
I'm having problems knowing what else I should do in order to let JEI know that my GUI is wider so it knows not to render on top. The GUI Code: public class GuiFactory extends GuiContainer { protected int xSize = 256; protected int ySize = 220; private static final ResourceLocation FACTORY_GUI_BACKGROUND = new ResourceLocation(ModInfo.MODID + ":textures/gui/container/factory_base.png"); public GuiFactory(Container inventorySlotsIn) { super(inventorySlotsIn); } /** * Draws the screen and all the components in it. */ @Override public void drawScreen(int par1, int par2, float par3) { this.drawDefaultBackground(); // This makes the background go darker super.drawScreen(par1, par2, par3); } /** * Draw the background layer for the GuiContainer (everything behind the items) */ @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(FACTORY_GUI_BACKGROUND); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); int i1; } /** * Draw the foreground layer for the GuiContainer (everything in front of the * items) */ @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRenderer.drawString(I18n.format("container.inventory"), -26, this.ySize - 122, 4210752); } }
-
[1.12.2] Check for free slot in player inventory
American2050 replied to xorinzor's topic in Modder Support
There is this method you can use also. Just check what int it returns and if it's on the range of inventory slots you want (Because I don't know if it would also return armor slots as empty slots) player.inventory.getFirstEmptyStack() Depending on what number you get, you will know that the player has a free slot. -
[Solved] Storing and Retrieving NBT for an Item
American2050 replied to shauncjones's topic in Modder Support
Looks like everytime something changes on the slots of your backpack you not saving those changes on the NBT (I may be wrong but check if that is happening) Also, not sure how you populate the slots, are those been fill with the contents you get from the NBT? -
[Solved][1.12] TileEntity does not deserialize on client
American2050 replied to SuperManitu's topic in Modder Support
I'm not that good to explain it, but take a look at this post and all the answers, you will find what you need here: -
So I was wondering, shouldn't the method onBlockActivated be called two times? One for each hand? I'm testing with a simple: @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { LogHelper.info("CALLED " + hand); On console I see: [17:29:34] [main/INFO] [LogHelper]: CALLED MAIN_HAND [17:29:34] [Server thread/INFO] [LogHelper]: CALLED MAIN_HAND I was expecting to see calls for OFF_HAND also. So my question here would be: Am I forgetting something, and if so, what? And if this is the way it's intended, how do I make it so the player "Swings" the off hand if the action tool place from that hand?
-
So, this is kinda related with other questions I made in the Forum. I have a block that onBlockActivated get some changes and those need to be notified so the client re-renders the model. So at the end of the onBlockActivated method I'm doing if (worldIn.isRemote) { // worldIn.markBlockRangeForRenderUpdate(pos, pos); worldIn.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); } Using that method, it's not until the 2nd time I right click the block, that the render updates correctly (I guess by the time it's called for some reason it still doesn't know about the changes) However if I use Minecraft.getMinecraft().renderGlobal.markBlockRangeForRenderUpdate(pos.getX(), pos.getY(), pos.getZ(), pos.getX(), pos.getY(), pos.getZ()); The model updates correctly. Why is this?
-
diesieben07 Thanks a lot for the time you take answering this questions and clarifying all the points. I believe that I finally have a better understanding on what's happening and when it's happening and more important, on how to handle this things. I'm gonna start implementing all this and let you know how it went. I was super super lost because I'm using a lot of things I never experiment with before. Special Rendering for my block, extended unlisted properties, and all this data sync across server and client. Tons of stuff going on at the same time, and I unsure on how to implement all of those, so it literally fell like 1 step forward and 10 back for each thing I got working. Always hitting some bump Thanks once again.
-
Thanks a lot for all this, great information. Some points here. I used the getUpdateTag because I was following a tutorial and example code from MinecraftByExamples on the TileEntities examples https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe20_tileentity_data (so now I have the 4 methods suggested there getUpdatePacket(), getUpdateTag(), onDataPacket(), and handleUpdateTag() been overriden. Now going with the thinking of "I store things in my TileEntity" problem comes when I change a variable on my TileEntity but those changes are made server only, then the client doesn't know about them until writeToNBT and readFromNBT are called. I have a point on my TileEntity after I set x ItemStack to any given side, at the end of that method I call this.markDirty (But you mention I shouldn't care of "When" that happens) I would like for it to happen inmediatly, so my block knows about the changes. Now on my block, on the method onBlockActivated (And server side) I set the ItemStacks on my tile entity and, after that is done I am calling .notifyBlockUpdate on the client side. It's not until the 2nd time I right click that you can see the render update (At this point I'm not sure if it's because the first time it's called, it still doesn't have the information of what ItemStack is on X side or what) I will have to see what's going on there. PS: What do you mean with "ignore ItemStacks they are terrible"? You mean why I'm storing itemstacks on my TileEntity this way?
-
[1.7.10] EZ Storage GUI Causing Crash?
American2050 replied to Banne's topic in Support & Bug Reports
This is forge Forums. If you think the crash is caused by EZ Storage report here: https://github.com/zerofall/EZStorage/issues PS: I also see at com.domochevsky.territories.Items.TerritoryMap.func_77624_a(TerritoryMap.java:188) whatever that is may be the cause of the crash also. -
Apparently the problem is that the server isn't receiving the updated information. This is a log when loading a world with one of my TileEntities placed on it... [09:35:44] [Server thread/INFO] [LogHelper]: CALLED HERE ON READ!!! [09:35:44] [Server thread/INFO] [LogHelper]: COMPOUND ON READ IS: {ForgeData:{factory.data:{factory.panels:{east:{id:"minecraft:air",Count:1b,Damage:0s},south:{id:"minecraft:air",Count:1b,Damage:0s},north:{id:"minecraft:air",Count:1b,Damage:0s},west:{id:"minecraft:air",Count:1b,Damage:0s},up:{id:"minecraft:air",Count:1b,Damage:0s},down:{id:"minecraft:air",Count:1b,Damage:0s}}}},x:52,y:83,z:269,id:"factoryblock:te_factory",factory.data:{factory.panels:{east:{id:"minecraft:air",Count:0b,Damage:0s},south:{id:"minecraft:air",Count:0b,Damage:0s},north:{id:"minecraft:air",Count:0b,Damage:0s},west:{id:"minecraft:air",Count:0b,Damage:0s},up:{id:"minecraft:air",Count:0b,Damage:0s},down:{id:"minecraft:air",Count:0b,Damage:0s}}}} [09:35:44] [Server thread/INFO] [LogHelper]: HAS TAG ON READ [09:35:44] [Server thread/INFO] [LogHelper]: HAS PANELS ON READ [09:35:49] [Server thread/INFO] [LogHelper]: COMPOUND ON WRITE IS: {ForgeData:{factory.data:{factory.panels:{east:{id:"minecraft:air",Count:1b,Damage:0s},south:{id:"minecraft:air",Count:1b,Damage:0s},north:{id:"minecraft:air",Count:1b,Damage:0s},west:{id:"minecraft:air",Count:1b,Damage:0s},up:{id:"minecraft:air",Count:1b,Damage:0s},down:{id:"minecraft:air",Count:1b,Damage:0s}}}},x:52,y:83,z:269,id:"factoryblock:te_factory",factory.data:{factory.panels:{east:{id:"minecraft:air",Count:0b,Damage:0s},south:{id:"minecraft:air",Count:0b,Damage:0s},north:{id:"minecraft:air",Count:0b,Damage:0s},west:{id:"minecraft:air",Count:0b,Damage:0s},up:{id:"minecraft:air",Count:0b,Damage:0s},down:{id:"minecraft:air",Count:0b,Damage:0s}}}} [09:35:49] [Server thread/INFO] [LogHelper]: HAS TAG ON WRITE [09:35:49] [Server thread/INFO] [LogHelper]: HAS PANELS ON WRITE [09:35:49] [Server thread/INFO] [LogHelper]: HAS up ON WRITE [09:35:49] [main/INFO] [LogHelper]: CALLED HERE ON READ!!! [09:35:49] [main/INFO] [LogHelper]: COMPOUND ON READ IS: {ForgeData:{factory.data:{factory.panels:{east:{id:"minecraft:air",Count:1b,Damage:0s},south:{id:"minecraft:air",Count:1b,Damage:0s},north:{id:"minecraft:air",Count:1b,Damage:0s},west:{id:"minecraft:air",Count:1b,Damage:0s},up:{id:"minecraft:air",Count:1b,Damage:0s},down:{id:"minecraft:air",Count:1b,Damage:0s}}}},x:52,y:83,z:269,id:"factoryblock:te_factory"} [09:35:53] [Server thread/INFO] [LogHelper]: COMPOUND ON WRITE IS: {ForgeData:{factory.data:{factory.panels:{east:{id:"minecraft:air",Count:1b,Damage:0s},south:{id:"minecraft:air",Count:1b,Damage:0s},north:{id:"minecraft:air",Count:1b,Damage:0s},west:{id:"minecraft:air",Count:1b,Damage:0s},up:{id:"minecraft:air",Count:1b,Damage:0s},down:{id:"minecraft:air",Count:1b,Damage:0s}}}},x:52,y:83,z:269,id:"factoryblock:te_factory",factory.data:{factory.panels:{east:{id:"minecraft:air",Count:0b,Damage:0s},south:{id:"minecraft:air",Count:0b,Damage:0s},north:{id:"minecraft:air",Count:0b,Damage:0s},west:{id:"minecraft:air",Count:0b,Damage:0s},up:{id:"minecraft:air",Count:0b,Damage:0s},down:{id:"minecraft:air",Count:0b,Damage:0s}}}} [09:35:53] [Server thread/INFO] [LogHelper]: HAS TAG ON WRITE [09:35:53] [Server thread/INFO] [LogHelper]: HAS PANELS ON WRITE [09:35:53] [Server thread/INFO] [LogHelper]: HAS up ON WRITE [09:35:53] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether [09:35:53] [Server thread/INFO]: Saving chunks for level 'New World'/the_end This are the differences I notice: The Write was only called on server. And when the read is called both, Server and Client side, the information on the NBT is different SERVER on READ {ForgeData:{factory.data: {factory.panels:{ east:{id:"minecraft:air",Count:1b,Damage:0s}, south:{id:"minecraft:air",Count:1b,Damage:0s}, north:{id:"minecraft:air",Count:1b,Damage:0s}, west:{id:"minecraft:air",Count:1b,Damage:0s}, up:{id:"minecraft:air",Count:1b,Damage:0s}, down:{id:"minecraft:air",Count:1b,Damage:0s}}}}, x:52,y:83,z:269,id:"factoryblock:te_factory", factory.data: {factory.panels:{ east:{id:"minecraft:air",Count:0b,Damage:0s}, south:{id:"minecraft:air",Count:0b,Damage:0s}, north:{id:"minecraft:air",Count:0b,Damage:0s}, west:{id:"minecraft:air",Count:0b,Damage:0s}, up:{id:"minecraft:air",Count:0b,Damage:0s}, down:{id:"minecraft:air",Count:0b,Damage:0s}}}} CLIENT on READ {ForgeData:{factory.data: {factory.panels:{ east:{id:"minecraft:air",Count:1b,Damage:0s}, south:{id:"minecraft:air",Count:1b,Damage:0s}, north:{id:"minecraft:air",Count:1b,Damage:0s}, west:{id:"minecraft:air",Count:1b,Damage:0s}, up:{id:"minecraft:air",Count:1b,Damage:0s}, down:{id:"minecraft:air",Count:1b,Damage:0s}}}}, x:52,y:83,z:269,id:"factoryblock:te_factory"} What I don't understand why is the ForgeData there? And how the client go it? PS: I guess the fix for this is to work with packets now? I remember I saw something about overwriting 4 packet methods for TileEntities but will have to read about this as I have not idea. This is my TE code now after cleanup: package org.bitbucket.factoryblock.tileentity; import org.bitbucket.factoryblock.LogHelper; import org.bitbucket.factoryblock.enums.EnumPanels; import org.bitbucket.factoryblock.interfaces.IPanel; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; public class TileEntityFactory extends TileEntity implements ITickable, net.minecraft.client.renderer.texture.ITickable { public static final String TAG = "factory.data"; public static final String PANELS = "factory.panels"; private ItemStack stackPanelUp = ItemStack.EMPTY; private ItemStack stackPanelDown = ItemStack.EMPTY; private ItemStack stackPanelEast = ItemStack.EMPTY; private ItemStack stackPanelWest = ItemStack.EMPTY; private ItemStack stackPanelNorth = ItemStack.EMPTY; private ItemStack stackPanelSouth = ItemStack.EMPTY; public TileEntityFactory() { } @Override public void update() { // TODO Auto-generated method stub } // TODO Do we need this? @Override public void tick() { // TODO Auto-generated method stub } public void setPanelAt(EnumFacing facing, ItemStack stack) { switch (facing) { case UP: this.stackPanelUp = stack; break; case DOWN: this.stackPanelUp = stack; break; case EAST: this.stackPanelUp = stack; break; case WEST: this.stackPanelUp = stack; break; case NORTH: this.stackPanelUp = stack; break; case SOUTH: this.stackPanelUp = stack; break; } // This Force NBT Update? this.markDirty(); } public EnumPanels getPanelTypeAt(EnumFacing facing) { switch (facing) { case UP: if (this.stackPanelUp.getItem() instanceof IPanel) { IPanel thePanel = (IPanel) this.stackPanelUp.getItem(); return thePanel.getPanelType(); } case DOWN: if (this.stackPanelDown.getItem() instanceof IPanel) { IPanel thePanel = (IPanel) this.stackPanelDown.getItem(); return thePanel.getPanelType(); } case EAST: if (this.stackPanelEast.getItem() instanceof IPanel) { IPanel thePanel = (IPanel) this.stackPanelEast.getItem(); return thePanel.getPanelType(); } case WEST: if (this.stackPanelWest.getItem() instanceof IPanel) { IPanel thePanel = (IPanel) this.stackPanelWest.getItem(); return thePanel.getPanelType(); } case NORTH: if (this.stackPanelNorth.getItem() instanceof IPanel) { IPanel thePanel = (IPanel) this.stackPanelNorth.getItem(); return thePanel.getPanelType(); } case SOUTH: if (this.stackPanelSouth.getItem() instanceof IPanel) { IPanel thePanel = (IPanel) this.stackPanelSouth.getItem(); return thePanel.getPanelType(); } } return EnumPanels.EMPTY; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); // DATA NBTTagCompound data = new NBTTagCompound(); // PANELS NBTTagCompound panels = new NBTTagCompound(); panels.setTag("up", this.stackPanelUp.writeToNBT(new NBTTagCompound())); panels.setTag("down", this.stackPanelDown.writeToNBT(new NBTTagCompound())); panels.setTag("east", this.stackPanelEast.writeToNBT(new NBTTagCompound())); panels.setTag("west", this.stackPanelWest.writeToNBT(new NBTTagCompound())); panels.setTag("north", this.stackPanelNorth.writeToNBT(new NBTTagCompound())); panels.setTag("south", this.stackPanelSouth.writeToNBT(new NBTTagCompound())); // STORE PANELS ON DATA data.setTag(PANELS, panels); // STORE DATA ON A MAIN TAG compound.setTag(TAG, data); LogHelper.info("COMPOUND ON WRITE IS: " + compound); if (compound.hasKey(TAG)) { LogHelper.info("HAS TAG ON WRITE"); NBTTagCompound temp = compound.getCompoundTag(TAG); if (temp.hasKey(PANELS)) { LogHelper.info("HAS PANELS ON WRITE"); NBTTagCompound temp_panels = temp.getCompoundTag(PANELS); if (temp_panels.hasKey("up")) { LogHelper.info("HAS up ON WRITE"); } } } return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); LogHelper.info("CALLED HERE ON READ!!!"); LogHelper.info("COMPOUND ON READ IS: " + compound); if (compound.hasKey(TAG)) { LogHelper.info("HAS TAG ON READ"); NBTTagCompound data = compound.getCompoundTag(TAG); if (data.hasKey(PANELS)) { LogHelper.info("HAS PANELS ON READ"); NBTTagCompound panels = data.getCompoundTag(PANELS); this.stackPanelUp = new ItemStack(panels.getCompoundTag("up")); this.stackPanelDown = new ItemStack(panels.getCompoundTag("down")); this.stackPanelEast = new ItemStack(panels.getCompoundTag("east")); this.stackPanelWest = new ItemStack(panels.getCompoundTag("west")); this.stackPanelNorth = new ItemStack(panels.getCompoundTag("north")); this.stackPanelSouth = new ItemStack(panels.getCompoundTag("south")); } } } /* * @Override * public NBTTagCompound getUpdateTag() { * return super.getUpdateTag(); * } */ }
-
Ohhh ok, so I don't need to worry about storing the values for the first time when the TileEntity is placed in the world? I was doing this so, when I call methods from the Block, for example onBlockActivated I already "know" and can be "sure" that the TileEntity already has default values. But I guess I check against variables and not the data on the NBT right? Like if I want to change the value of for example ItemStack on side "UP" I just change the value of that variable and whenever Minecraft calls the writeToNBT it will update that value? Thanks, and sorry for so many questions NBT was/is (and hopefully not will always be) a shady part on codding that I never clearly understand.
-
Ohh ok. Well a friend told me that apparently I should never call the writeToNBT myself, not sure where he saw that. Is it ok to call it from the createNBT method that I have in my constructor, so each time the tileentity is set on the world, it creates the default values? PD: I had the getTileData at the constructor as // this.getTileData().setTag(PANELS, createNBTData());
-
Also... Independent of the fact that I was missing to write the tag PANELS... How come it's there on the NBT I receive, but the hasKey still is false? @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { // this is called by minecraft to give you the posibility to update your NBT before being saved to the world super.writeToNBT(compound); LogHelper.info("CALLED WRITE " + compound + " content"); if (compound.hasKey(PANELS)) { LogHelper.info("HAS PANELS"); } Console shows: [08:35:04] [Server thread/INFO] [LogHelper]: CALLED WRITE {ForgeData:{factory.panels:{east:{id:"minecraft:air",Count:1b,Damage:0s},south:{id:"minecraft:air",Count:1b,Damage:0s},north:{id:"minecraft:air",Count:1b,Damage:0s},west:{id:"minecraft:air",Count:1b,Damage:0s},up:{id:"minecraft:air",Count:1b,Damage:0s},down:{id:"minecraft:air",Count:1b,Damage:0s}}},x:50,y:83,z:272,id:"factoryblock:te_factory"} content but HAS PANELS never shows... isn't {ForgeData:{factory.panels:{east:{id indicating the precense of the tag PANELS there, or I'm missing something?
-
Yes now that I see the writeToNBT I noticed that, but how come that when I print the compound to the console it does show the tag PANELS there and the default values for each side? PS: the createNBT is implemented correctly? Is it ok to call it from the constructor? Thanks a lot.
-
Here: @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { // this is called by minecraft to give you the posibility to update your NBT before being saved to the world super.writeToNBT(compound); compound.setTag("up", this.stackPanelUp.writeToNBT(new NBTTagCompound())); compound.setTag("down", this.stackPanelDown.writeToNBT(new NBTTagCompound())); compound.setTag("east", this.stackPanelEast.writeToNBT(new NBTTagCompound())); compound.setTag("west", this.stackPanelWest.writeToNBT(new NBTTagCompound())); compound.setTag("north", this.stackPanelNorth.writeToNBT(new NBTTagCompound())); compound.setTag("south", this.stackPanelSouth.writeToNBT(new NBTTagCompound())); return compound; } The whole class, just in case: PS: I believe I now see the problem But lets see...
-
Not everyone knows everything. You could suggest it on a nice way. Stop been like that all the time.