
Raycoms
Members-
Posts
383 -
Joined
-
Last visited
Everything posted by Raycoms
-
Hey there, I'm creating our own implementation of the minecraft chest which will be more effective for iterating automatically over it (Some background processes of our mod require it) but should be almost identical for player use (it only sorts automatically). We store the stacks in a HashMap which contains extendedStacks (which contain the itemStack + the amount (unlimited)). Dropping off and getting items manually works fine. But, if I drop items off by double click in the inventory or retrieve items by double click in the chest strange things happen: Double click in chest: All my inventory fills up with the item Double click in inventory: Item goes into the inventory but vanishes after reopening very often. It also doesn't store the inventory content after restarting Thanks for the help already package com.minecolonies.coremod.tileentities; import com.minecolonies.coremod.util.ExtendedItemStack; import com.minecolonies.coremod.util.InventoryUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntityChest; import javax.annotation.Nullable; import java.util.HashMap; public class TileEntityMinecoloniesChest extends TileEntityChest { private final HashMap<ExtendedItemStack, ExtendedItemStack> content = new HashMap<>(); public TileEntityMinecoloniesChest() { super(); } /** * Returns the stack in the given slot. */ @Nullable @Override public ItemStack getStackInSlot(int index) { int i = 0; for (final ExtendedItemStack stack : content.values()) { int totalAmount = stack.getAmount(); double divisor = Math.max(64, totalAmount) / 64.0; for (int partialStacks = 0; partialStacks < divisor; partialStacks++) { int size = Math.min(64, totalAmount); if (i + partialStacks == index) { final ItemStack returnStack = stack.getStack(); returnStack.stackSize = size; return returnStack; } totalAmount -= size; } i += divisor; } return InventoryUtils.EMPTY; } @Override public NBTTagCompound serializeNBT() { final NBTTagCompound compound = super.serializeNBT(); final NBTTagList nbttaglist = new NBTTagList(); for (final ExtendedItemStack stack : content.values()) { stack.writeToNBT(compound); } compound.setTag("Items", nbttaglist); return compound; } @Override public void deserializeNBT(final NBTTagCompound nbt) { super.deserializeNBT(nbt); final NBTTagList nbttaglist = nbt.getTagList("Items", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { final NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); final ExtendedItemStack stack = ExtendedItemStack.readFromNBT(nbttagcompound); content.put(stack, stack); } } /** * Removes up to a specified number of items from an inventory slot and returns them in a new stack. */ @Nullable @Override public ItemStack decrStackSize(int index, int count) { this.markDirty(); int i = 0; for (final ExtendedItemStack stack : content.values()) { int totalAmount = stack.getAmount(); double divisor = Math.max(64, totalAmount) / 64.0; for (int partialStacks = 0; partialStacks < divisor; partialStacks++) { int size = Math.min(64, totalAmount); if (i + partialStacks == index) { final ItemStack returnStack = stack.getAsItemStackWithAmount(count); if (stack.getAmount() == 0) { content.remove(stack); } return returnStack; } totalAmount -= size; } i += divisor; } return InventoryUtils.EMPTY; } /** * Removes a stack from the given slot and returns it. */ @Nullable @Override public ItemStack removeStackFromSlot(int index) { this.markDirty(); int i = 0; for (final ExtendedItemStack stack : content.values()) { int totalAmount = stack.getAmount(); double divisor = Math.max(64, totalAmount) / 64.0; for (int partialStacks = 0; partialStacks < divisor; partialStacks++) { int size = Math.min(64, totalAmount); if (i + partialStacks == index) { return stack.getAsItemStackWithAmount(size); } totalAmount -= size; } i += divisor; } return InventoryUtils.EMPTY; } /** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). */ @Override public void setInventorySlotContents(int index, @Nullable ItemStack stack) { if (stack == null) { return; } if (content.containsKey(new ExtendedItemStack(stack, 0))) { ExtendedItemStack ext = content.remove(new ExtendedItemStack(stack, 0)); ext.increaseAmount(stack.stackSize); content.put(ext, ext); } else { final ExtendedItemStack ext = new ExtendedItemStack(stack, stack.stackSize); content.put(ext, ext); } stack.stackSize = 0; this.markDirty(); } public boolean addItemStackToInventory(@org.jetbrains.annotations.Nullable final ItemStack itemStackIn) { return true; } /** * Clear the inventory. */ @Override public void clear() { content.clear(); } }
-
I also tried to use "normal". Rendering, animation all works fine for the chest. Only thing missing are really the particle effects.
-
okay, I just remembered I can simply drop a normal chest. I won't need the chest item in the inventory. I just have to replace the chest on placement. Anyway, here: ModelLoader.setCustomStateMapper(ModBlocks.blockMinecoloniesChest, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(final IBlockState state) { return new ModelResourceLocation(ModItems.permTool.getRegistryName(), INVENTORY) ; } }); I have "inventory". I think that isn't completely right. How do I get the ModelResourceLocation for the correct block? (It works already quite well, the only problem are the particle effects)
-
I mean I could simply copy the blockState and model and texture of minecraft and use that. But I wanted to avoid that. I mean if the models and items are already there in minecraft why can't I use them.
-
Problem №1. Chests don't have a normal inventory model. Their rendering is built-in. So how do I manage this?
-
Hey there, For our mod we want to copy the minecraft blockChest code and create a proxy between it. The idea would be that the player thinks he is interacting with a normal chest, while he is really interacting with our special chest. ModelLoader.setCustomStateMapper(ModBlocks.blockMinecoloniesChest, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(final IBlockState state) { return new ModelResourceLocation(ModItems.permTool.getRegistryName(), INVENTORY) ; } }); itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockMinecoloniesChest), 0, new ModelResourceLocation(Blocks.CHEST.getRegistryName(), INVENTORY)); I used these two to register the renderer. And I made a copy of the tileEntity and the block. But, unfortunately, I'm not able to see the block in my inventory (the world block renders just fine) Exception on loading: Additionally: public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); when I call super.readFromNbt it does give me an exception:
-
-.- Like I said PlayerList::canSendCommands checks if the player is able to send a certain command. Which, even on a server and not op, he might be due to a permission mod. Therefore, this doesn't work.
-
The problem is that the permission mod only allows binary decisions. Allow a command completely without restrictions or don't allow a command. But since we want to check inside the command the op level of the player, and the permission plugin gives him completely op for that command, this doesn't work. That's why we want a general way to decide it. Thought about checking if the player is allowed to execute a certain sort of commands like gamemode, ban or kick, but that isn't that reliable as well.
-
Yeah me neither. But for some reason a permission node does open a certain command completely.
-
We have custom commands players can call. One of them, for example, is "delete colony". Ops can delete everyone's colonies, players only their owns. In singlePlayer or lan we check if they have op the normal way and if not we restrict the usage. But on a server with permission nodes. We have to allow the whole command usage, and, the player gains op level for that execution because of that.
-
The problem with this is that most permission plugins seem to use permission node which give the player the ability to use certain commands. This seems to give them op in this sense and doesn't work for us I think.
-
sorry that player snuck in there. Its "op level of a specific player"
-
Is there a reliable way to get the op level of a specific player on a server? We currently use: FMLCommonHandler.instance().getMinecraftServerInstance().canUseCommand(requiredOpLevel, cmdName) where requiredOpLevel is the required Op level for a certain action. Seems to work well in smp and ssp but doesn't work at all on sponge servers or similar. Is there a better way?
-
Server down - problem with mathHelper clampInt [1.10]
Raycoms replied to Raycoms's topic in Modder Support
Fixed the problem. Always when tests are failing the jar ends up being deobf. -
Server down - problem with mathHelper clampInt [1.10]
Raycoms replied to Raycoms's topic in Modder Support
Like always buildGradle with travis And it created this: https://www.dropbox.com/sh/9cnqcjl0nan57cy/AAB8tv-J7awi-O-BBejOpgkNa/branch/hotifx/mathhelper-crash?dl=0 And I tried the universal one not the deobf one. -
I changed some very small details in our code (Added some lines in ColonyList.java and renamed a file in the assets to upper case) It runs perfectly well in intellij, but when I produce the jar all of our users and our official servers throw an error:
-
the FakePlayerFactory doesn't contain a list of all fakePlayers? I can't just search them for the incoming name?
-
But still. I want the players only to add valid players or valid fakePlayers and nothing besides that. Therefore I need a way to detect if it is really a fakePlayer.
-
I don't but we're not able to get the UUID of the fakePlayer entity the same way we get the UUID of the normal player. GameProfile gameprofile = world.getMinecraftServer().getPlayerProfileCache().getGameProfileForUsername(player);
-
To allow the fakePlayer work execute work inside the defined protected area.
-
We need to be able to detect automatically if the entered name is a "FakePlayerName" and we need to get its GameProfile.
-
That would be bad for all anti griefing mods. [Mekanism] - Mekanism[BuildCraft] - BuildCraft[Forestry] - Forestry ComputerCraft - ComputerCraft[OpenComputers] - Open Computers[Stevescart] - Steve's Carts[MineFactory] - MineFactoryReloaded[CoFH] - Autonomous Activator[SFM_PLAYER] - Steve's Factory Manager[EioFarmer] - Ender IO FarmerFakeThaumcraftGolem - Thaumcraft GolemsFakeThaumcraftBore - Thaumcraft Arcane Bore[EioKillera] - Ender IO KillerJoe[Minecraft] - Extra Utilities This is a list of all the "well known" fake players of various mods. I hope these mods have taken these usernames to avoid griefing by them.
-
Ender IO only offers a name as far as I know "EioKillera" so that players can add them to the mods which implement anti griefing protection.
-
If a player wants a fakePlayer to be able to make changes to the terrain in the colony he has to add him to the colony to give him permission. Some mods offer a "Username" of this fakePlayer.
-
The player types this username to add him to his colony. We then get the UUID from the username and add the uuid and username to the colony. But this doesn't work for fakePlayers