
Anubis
Members-
Posts
40 -
Joined
-
Last visited
Everything posted by Anubis
-
I created a server side recipe and want the mod to mainly run on the server. The goal is to create a custom item from the crafting what is handled most easily with a recipe. Trying on a single player world worked fine. Sadly, the registrys seem to make issues. When trying to connect to the server, there comes the error: "failed to synchronize registry data from the server, closing connection" Is there anything I can do to fix that? Can I trick the client to ignor the the recipe in any way? Would be happy over any suggestions
-
Different name for Launch Files generated by gradle
Anubis replied to Anubis's topic in Modder Support
I know I can do this, but this not permanently. After next build with gradle, for example after forge update, I have to do it again. I would like to set it in the gradle or something, so it is always set after every build -
Using different projects simultaneously, sometimes to compare different aspects of the code or because of working on multiple at a time I allways have one Issue with eclipse: All launch files generated with gradle have the same name (runClient.launch etc.). And I can't figure out how to chance the name in the gradle without breaking them. You can add the mod name at the build.grade to the runs { client { part to set them run { client_modname { and this changes the name of the launchfile (runClient_modname) but eclipse then doesn't know the main class anymore and it is not usable anymore (resp. you have to put in the main class every time but then I can also change the launch file name afterwards, which is not the goal). Has anyone an idea what I can do? I normally don't do much with the gradle part, I am just happy it works. But the same name of the launch-file for all projects is very confusing some times and it would be quit helpful if I could change this. Thanks for reply
-
I hope it is right in this way: https://github.com/AlmightyAnubis/Ore_Test
-
If you are still interested, I uploaded the code to github: https://github.com/AlmightyAnubis/Crushing_Project Would be a great honor, if a expert like you will check for mistakes. Many things where I couldn't find a good answer in the internet and looked in the minecraft code to copy similar behavior, which resulted in botching in some cases I guess... But I know, that you have better thinks to do, so now problem if you don't have time for that. I deleted all the json files, because github forced me to 100 files upload limit. But many of them can be recovered with a run of runData
-
Ok, I thanks. I will use setBlockState. The code was a bit older, so I don't know why I used notifyBlockUpdate, but I checked setBlockState and it seems to call notifyBlockUpdate finally to. It calls markAndNotifyBlock which calls notifyBlockUpdate after much more other logic. I like to prevent other logics and the the process time comes down. I think this is why I used notifyBlockUpdate in the first case. But when you say setBlockState is the better way, I will trust you. I work in 1.15, i don't know if there is a difference to other versions.
-
Yes I know. My block has 2 states, weather it is working or not. See pictures below. The working state: The default state: The gui: The Gui in progress: The recipes have there own working time, so when you click the recipe you want, the work time is read from the recipe. Here is on example recipe: { "type": "crushing_project:lumbermilling", "ingredients": [ { "item": "crushing_project:throable_flint", "count": 2 } ], "result": "crushing_project:flint_and_flint", "count": 1, "crafttime": 50 } I don't use github at the moment, so posting wont help me so much, especially because my problems are solved. Thanks for the help.
-
So, only call it on start an end of the crafting progress? Max work time is the end time and is include in the json of the recipe, the current work time is the time which is ticking and resets at the end. So while no recipe is executed, the current work time is 0 and the progress bar stays at 0%. And when recipe starts, the max work time is defined, so the scaling can be done with every recipe on its own.
-
Ok, I remove the isRemote check in the tile entity. Now it works, but can this create any other issues?
-
I created a tile entity, that can perform a crafting operation. Everything works as expected, but when I close the screen while working and open it after it has finished, the sceen shows the progress of when I closed the screen. Starting a new craftingoperation solves the problem, but this isn't right. I used the FunctionalIntReferenceHolder to keep track of the values of the tile entity, but I am not sure if this is the right way. Here is my code: The screen: private void drawProgress() { RenderSystem.color4f(1F, 1F, 1F, 1F); minecraft.getTextureManager().bindTexture(BACKGROUND); int up = 0; int left = xSize; int down = ySizeProgress; int currentTime = this.container.currentWorktime.get(); int maxTime = this.container.maxWorktime.get(); int right = (int) Math.round(xSizeProgress * currentTime / maxTime); int gui_grafic_size = 256; blit(guiLeft + 52, guiTop + 56, left, up, right, down, gui_grafic_size, gui_grafic_size); } The container: @Override public void init() { tileEntity.getInventory().ifPresent(handler -> { addSlot(new SlotItemHandler(handler, 0, 20, 76)); addSlot(new SlotItemHandler(handler, 1, 139, 76)); }); addPlayerInventory(8, 113); this.trackInt(currentWorktime = new FunctionalIntReferenceHolder(() -> ((FlintFactoryTile_Entity) this.tileEntity).currentWorkTime, v -> this.tileEntity.currentWorkTime = v)); this.trackInt(maxWorktime = new FunctionalIntReferenceHolder( () -> ((FlintFactoryTile_Entity) this.tileEntity).maxWorkTime, v -> this.tileEntity.maxWorkTime = v)); currentWorktime.get(); maxWorktime.get(); } And the tile entity ticking part: @Override public void tick() { boolean dirty = false; if (world != null && !this.world.isRemote) { boolean work = false; if (this.factoryinventory.isPresent()) { Inventory inventory = getinventoryasInventory(); Inventory inputinv = new Inventory(inventory.getStackInSlot(0)); Inventory outputinv = new Inventory(inventory.getStackInSlot(1)); if (this.selectedRecipe != null) { ItemStack output = this.selectedRecipe.getCraftingResult(inputinv); boolean flag = inputinv.getStackInSlot(0).getCount() >= this.selectedRecipe.getIngredientCount(); if(!flag) { this.selectedRecipe=null; currentWorkTime=0; } work = outputinv.isEmpty() && flag; if (!work) { ItemStack itemStack = outputinv.getStackInSlot(0); boolean equal = itemStack.isItemEqual(output); boolean fitting = itemStack.getMaxStackSize() >= output.getCount() + itemStack.getCount(); work = equal && fitting && flag; } if (work) { dirty = true; if (this.currentWorkTime < this.maxWorkTime) { this.currentWorkTime++; } else { this.currentWorkTime = 0; outputinv.addItem(output); this.selectedRecipe = null; this.factoryinventory.ifPresent(consumer -> { consumer.setStackInSlot(1, outputinv.getStackInSlot(0)); consumer.getStackInSlot(0).shrink(2); }); } } } } this.world.setBlockState(this.getPos(), this.getBlockState().with(FlintFactoryBlock.WORKING, work)); } if (dirty) { this.markDirty(); this.world.notifyBlockUpdate(this.pos, this.getBlockState(), this.getBlockState(), Constants.BlockFlags.BLOCK_UPDATE); } Thanks for help
-
Maybe it was the hat and not the body or look vector from the LookRandomGoal. Now I used: Vec3d look =Vec3d.fromPitchYaw((float) Math.PI/2, this.entity.getRotationYawHead()); and it worked. Thanks for help
-
public boolean shouldExecute() { if (eatTimer == 0 && entity.getIdleTime() > 100) { BlockPos pos = this.entity.getPosition(); float width = this.entity.getWidth()/2; Vec3d look = this.entity.getLookVec(); look = look.add(0, -look.y, 0); look = look.scale(width); pos = pos.add(round(look.x), 0, round(look.z)); if (entity.world instanceof ServerWorld) { ServerWorld world = (ServerWorld) entity.world; for (int i = -1; i <= 1; i++) { if (blocks.contains(world.getBlockState(pos.add(0, i, 0)).getBlock())) { eatPos = pos.add(0, i, 0); eatWorld = world; entityPos = entity.getPosition(); eatTimer = entityEatTime; entity.setIdleTime(0); return true; } } } } return false; } This is the should executemethode of the goal. The look-vector always stays the same, so the entity couldn't find the block to eat.
-
I am not sure, but the entity model changed direction of look but the look vector didnt change... die he could only eat at one pos
-
I created my own goal, similar to the eat gras goal of the sheep. But my entity is a bit larger, so I used the entity.getLookVec(); to get the direction it is looking and multiplied by half of the width. But the entity always only picked one block, so I tracked everything and it seem that the look random goal only changes the looking of the Entity client side, but not server side. Am I right or am I doing something wrong. And is there a way to get it serverside? I tried the entity.getLookController(), but this also didn't work. Anyone an Idea?
-
Simulate mouse break block while window unfocused
Anubis replied to Anubis's topic in Modder Support
Thanks for all. Sorry, I am no fan of cheating but I hate, when my PC is blocked for mc and I cant do other stuff like modding How can I close topic? -
Simulate mouse break block while window unfocused
Anubis replied to Anubis's topic in Modder Support
Normally you can use F3 + T to reload resourses and keep the mouse clicked for using a cobble generator for example. But this requires mc to be focused and doesnt allow my computer to be used in an other context. I just want to allow my computer doing other stuff while simply breaking blocks in background. If the F3 + T combination is considert as cheating, then I am sorry for asking such questions her -
Simulate mouse break block while window unfocused
Anubis replied to Anubis's topic in Modder Support
Yeah, but when I play on a Server, the game keeps running So looking in the Methode I need the playercontroler with clickBlock right? -
Simulate mouse break block while window unfocused
Anubis replied to Anubis's topic in Modder Support
Doesnt this create a click on the current screen, so when I put MC in background, this simply clicks on the pause screen? -
I simply try to simulate the holding of the left mouse button to continuously break blocks, but with the ability to unfocuse the window. I found: KeyBinding.setKeyBindState(ClientProxy.mousePress.getKey(), keyDown); wich allows the wanted Key to be pressed, but requires the window to be focused. The other thing I found was: mc.player.swing(Hand.MAIN_HAND, true); resp. mc.player.swingArm(Hand.MAIN_HAND); But this only makes the wanted hand moving but without any influence on the surrounding. Looks funny, but is useless 😄 I call both commands in the ClientTickEvent and they were executed as expected. Any idea what I can do?
-
Ok, did something similar, but hoped, there was a better way Ok, I added a variable isSynced to the mob, wich is not stored in the read and write methode, so it resets when the entity is loaded and check this variable in tick and when it is false I sync the Entitys and set it to true so it isn't synced in the following ticks. This works but I don't know if it will cause issues in the future. Seams also to work if one player leaves the area. Dont know, if multiplayer will cause issues
-
I tried using Bi-Directional links, but I cant use the read methode to sync them, because they dont exist at this moment. What method is usable to put the Sync methods so the other entitys might be loadet? He acctually has the refrenced UUIDs via read, but he cant find the entitys because they dont exist when read is called. The read method: @Override public void read(CompoundNBT compound) { // TODO Auto-generated method stub super.read(compound); if (compound.contains("age")) { age = compound.getLong("age"); } else { age = 0; } if (compound.contains("hasHerd")) { setHasHerd(compound.getBoolean("hasHerd")); } else { setHasHerd(false); } if (compound.contains("herd")) { INBT nInbt = compound.get("herd"); if (nInbt instanceof CompoundNBT) { this.dataManager.set(HERD_UUID, (CompoundNBT) nInbt); } } if (compound.contains("leaderMost")) { this.dataManager.set(LEADER, Optional.ofNullable(compound.getUniqueId("leader"))); } if (compound.contains("isleader")) { this.dataManager.set(IS_LEADER, compound.getBoolean("isleader")); if (this.dataManager.get(IS_LEADER) == true) { syncId(); }else { updateLeaderfromFollower(); } } //syncId(); //not working here because entitys not loaded here } The code I am calling for the leader: public void syncId() { if (isServerWorld()) { ServerWorld serverWorld = (ServerWorld) world; CompoundNBT UUIDCompound = this.dataManager.get(HERD_UUID); ArrayList<UUID> uuids = CompoundNBT_Helper.readUUIDList("member", UUIDCompound); ArrayList<Integer> ids = new ArrayList<Integer>(); uuids.forEach((uuid) -> { Entity entity = serverWorld.getEntityByUuid(uuid); if(entity !=null) { ids.add(entity.getEntityId()); } }); CompoundNBT IDCompound = new CompoundNBT(); IDCompound = CompoundNBT_Helper.writeIntergerList("member", ids, IDCompound); this.dataManager.set(HERD_ID, IDCompound); } } The code I use for the followers: public boolean updateLeaderfromFollower() { if(world instanceof ServerWorld) { ServerWorld serverWorld = (ServerWorld) world; if(this.dataManager.get(LEADER).isPresent()) { Entity entity = serverWorld.getEntityByUuid(this.dataManager.get(LEADER).get()); if (entity != null) { if (entity instanceof Herd_Mob) { ((Herd_Mob) entity).syncId(); } } } } return false; }
-
Its not about the spawn of the entity. Its about reload after saving world. I saved the UUIDs via write and get them via read. But I need to sync the IDs when the player has joined with the UUIDs but that only works when all the enititys that are linked with UUID already exist/are loaded, otherwise they cant be referenced for getting the ID
-
One last Question: Syncing the IDs and the UUIDs is required when I load the world. Problem is, that the entitys are not loaded, when they load to sync. Is there a way to sync after the load of every entity so they already exist? Otherwise I get errors. Maybe hocking to the JoinWorldEvent? Or adding an extra goal for that? But this seems not right to me, more like a stopgap.
-
Ok, found it from you XD
-
Just a final question because I never did something like this and dont want to search endless if you know the answer instant. If not, I will search on my own. How can I check if F3 mod is activ, coodinates etc., because it should only render then