
44tim44
Members-
Posts
25 -
Joined
-
Last visited
44tim44's Achievements

Tree Puncher (2/8)
1
Reputation
-
Yeah, I'll try to learn capabilities. But, I'd rather start from a point where my code is already working, so I don't run into trouble. I do think I found the problem myself though: the variable totalChargeTime in TESolarPanel is not initialized unless an item is place in the charging slot in ContainerSolarPanel. Which is a bit stupid, since as you said, I don't even use the passed itemstack in getItemChargeTime() to calculate totalChargeTime.
-
1) Code is still WIP, and a lot of the code is copypasted from when I was only using batteries, and not cables. (Will be fixed) 2) See 1) The nullable is just an addon, so I don't have to pass an Itemstack to get the chargeRate. 3) See 1) 4) Because an Battery can give and take Charge, IChargeable can only take. (In the logic of my machines) 5) Because whenever I've tried to learn capabilities, I've run into troubles. I had troubles with capabilities attached to itemstacks not syncing properly between server and client. (I know I know, I should learn how to use capabilities properly, but I haven't yet. And this works in the meantime.) 6) Will fix. 7) Old code not cleaned up properly.
-
Update: If I use if(!world.isRemote){ chargingStation.increaseCharge(); } then everything works, except it won't start unless the SOLARPANEL is initialized, by placing a battery in the solarpanels charging-slot
-
Uh... Could you elaborate?
-
I've implemented an energy-cable-system in my mod, and I'm having trouble with the communication between the two machines on either side of a cable. I've made a generator, "SolarPanel", and a consumer, "Pulverizer". They both work perfectly, transferring generated energy from the solar panel to the pulverizer through the cable. (The cables forward what the machine on the opposite end of the cables is, to the the machine on the first end) However, I'm now implementing a second consumer, "ChargingStation", which is a battery-bank of sorts. It has an internal storage of energy. When my SolarPanel tries to use the ChargingStations increaseCharge()-method, the method executes, but the result; a higher energy-value in the storage, does not get recorded. In other words: if I'm looking at the GUI of the ChargingStation, I can see the energy in the storage increase, but as soon as I close (and reopen) the GUI, the value resets to 0. I assumed this was because of client/server mismatch, so I made the call of increaseCharge() from the SolarPanel check for !isRemote(), which solved the problem, but only if the ChargingStation is "initialized" by having it use increaseCharge() itself (which is done when the ChargingStation tries to charge using a battery in its inventory.) Otherwise, it never starts charging to begin with. Any help on how to fix this would be awesome. Thank you. Code: ChargingStation: https://github.com/44tim44/BetterThanElectricity_1.12.2/blob/master/src/main/java/se/sst_55t/betterthanelectricity/block/chargingstation/TileEntityChargingStation.java SolarPanel: https://github.com/44tim44/BetterThanElectricity_1.12.2/blob/master/src/main/java/se/sst_55t/betterthanelectricity/block/solarpanel/TileEntitySolarPanel.java Cable: https://github.com/44tim44/BetterThanElectricity_1.12.2/blob/master/src/main/java/se/sst_55t/betterthanelectricity/block/cable/TileEntityCable.java
-
Nevermind, managed to solve it on my own. My cables were referring back to the hub, so the hub got itself in its list of things to find the charge of, which resulted in a loop.
- 1 reply
-
- 1
-
-
Hi, I'm trying to implement a energy-cable system in my mod. My choice of algorithm was; Having the cables simply forward which generator it's connected to, to the machine on the other end of the cable. [G][C][C][C][M] (G = Generator, C = Cable, M = Machine) Now, I'm trying to implement a hub, which allows multiple generators to connect to one hub, which sums up the charge from the generators and sends it along its one output-side. [G][C] [H][C][M] [G][C] (G = Generator, C = Cable, M = Machine, H = Hub) However, I'm getting a StackOverflowError, when calculating the charge-sum in the hub. I'm not quite sure if I've accidentally programmed a recursive method, but I don't think so, and I'm unable to find why it's happening. All code is available at https://github.com/44tim44/BetterThanElectricity_1.12.2/tree/master/src/main/java/se/sst_55t/betterthanelectricity The hub's TE is block/multiSocket/TileEntityMultiSocketIn Any help is appreciated!
-
I do think my main problem, for the bug itself, was the fact that I didn't have a unique id when registering the Packet&Handler. *facepalm* But I still get "ByteBuf.release() was not called before it's garbage-collected." in my stacktrace from time to time. Is that because of something I did wrong? Because I can't find anyone else with the same problem on google (relating to minecraft).
-
I thought I was handling the packet on the main thread by using serverPlayer.getServerWorld().addScheduledTask(() -> { //Insert code here } ? So basically, in ItemJetpack, the only thing that should happen inside if(Minecraft.getMinecraft().gameSettings.keyBindJump.isKeyDown()) { //Insert code here } is sending a packet saying "Space is pressed" and let onMessage() handle everything? EDIT: Okay, nevermind. I just do it like I did before, but let the packet handle the decreasing of the charge, instead of settingCharge to what is clientSide. Thanks!
-
I've implemented a simple Jetpack in my mod, which utilizes the damagevalue of the item to hold it's batterycharge. The majority of the code is executed client-side, since it requires KeyInput from the player, hence I update the charge drained on the server with a custom Packet. However, at seemingly random times, the charge of the item is reset to a higher value, for seemingly no reason. (Only tested during Multiplayer-play.) Something that might be related is the fact that I sometime get a "ByteBuf.release() was not called before it's garbage-collected.", which I've been unable to find the reason for. Code: https://github.com/44tim44/BetterThanElectricity_1.12.2 The jetpack itself is in item>ItemJetpack.java The jetpack-packet is in network/PacketToServerJetpack.java Thanks!
-
[1.12] Custom double_slab being handled as a half_slab??
44tim44 replied to 44tim44's topic in Modder Support
Wow. I guess I am an idiot. Thanks! -
[1.12] Custom double_slab being handled as a half_slab??
44tim44 replied to 44tim44's topic in Modder Support
That fixed it! I changed is BlockPane to this and now it works! public static boolean isBlockPane(IBlockState state) { return state.getBlock() instanceof BlockSlabVerticalBase && !((BlockSlabVerticalBase) state.getBlock()).isDouble(); } But since I've already started this thread I'm gonna hijack it and ask for help with the collision boxes too. The Vertical Slabs don't have the correct collision boxes. Even though I am overriding addCollisionBoxToList the Vertical Slabs still have "full block" collision boxes. And I have no idea why. Github is up to date. -
[1.12] Custom double_slab being handled as a half_slab??
44tim44 replied to 44tim44's topic in Modder Support
Yeah, sorry wasn't aware of the package naming conventions. I fixed that, and all the other things you mentioned, except for EntityEntryBuilder. Gonna take a look at that later. I've cleaned up my repo now, and it should compile properly now. Sorry, and thanks! https://github.com/44tim44/BetterThanElectricity -
So, I've implemented sideways-slabs, and I'm trying to add a outer/inner corner effect on them, just like stairs have. I'm having a few problems with collisionBoxes, but that's beside the point for now. Now, my problem: For some reason, I get this error, when placing a sideways-double-slab: java.lang.IllegalArgumentException: Cannot get property PropertyEnum{name=position, clazz=class com.bte.mod.block.BlockSlabVerticalBase$EnumPosition, values=[north, south, east, west]} as it does not exist in BlockStateContainer{block=bte:smoothstone_vertical_doubleslab, properties=[]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204) at com.bte.mod.block.BlockSlabVerticalBase.getPaneShape(BlockSlabVerticalBase.java:134) at com.bte.mod.block.BlockSlabVerticalBase.getActualState(BlockSlabVerticalBase.java:122) Which makes NO sense, since this is what the code looks like in BlockSlabVerticalBase.getActualState(): public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { if(isDouble()) { return state; } else { return state.withProperty(SHAPE, getPaneShape(state, worldIn, pos)); } } For some reason, the instance of bte:smoothstone_vertical_doubleslab seems to return isDouble() as false, even though it's class has: @Override public boolean isDouble() { return true; } I'm going insane trying to figure out why this is happening... All my code is available on https://github.com/44tim44/BetterThanElectricity in case you want to check on anything. Any help at all would be tremendously appreciated!
-
Hi. I'm planning to make a sliding door, but I'm uncertain on how to go about implementing it. I'd like to avoid too complex multi-block structures because I don't really know enough about how to make them. Instead I've been thinking of simply having a normal door (albeit with a different model) that is somehow animated, to simulate the door sliding open, when interacted with. However, I'm not sure how to best achieve the effect. The ideas I have so far: - Spawning an entity, replacing the "closed door"-block, have the entity move to desired position and then replace the entity with an "open door"-block. - Simulate the pushing effect of a block being pushed by a piston - Making the door based on the piston itself. Essentialy making a pseudo piston which is unable to push things, and simply acts as an extendable block. I'm quite new to minecraft modding, and I'm definitely no expert at java, but I do know it. Any help at all would be appreciated!