-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix item changes not properly synced to client
- Loading branch information
Showing
5 changed files
with
135 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/reobf/proghatches/main/mixin/mixins/MixinRemoveUnunsedItemStackCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package reobf.proghatches.main.mixin.mixins; | ||
|
||
import java.util.List; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import com.gtnewhorizons.modularui.common.internal.wrapper.ModularUIContainer; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.inventory.Container; | ||
|
||
@Mixin(value = ModularUIContainer.class, remap = false) | ||
public abstract class MixinRemoveUnunsedItemStackCache extends Container{ | ||
|
||
|
||
/* | ||
addSlotToContainer() in Container.java will add to both inventorySlots and inventoryItemStacks | ||
removeSlot() in ModularUIContainer.java only remove inventorySlots | ||
that means open and close a child window with slotwidgets will lengthen inventoryItemStacks | ||
this mixin will fix this potential leak | ||
*/ | ||
|
||
private int length; | ||
@Inject(method = "removeSlot", at = @At(value = "HEAD"), require = 1, cancellable = false) | ||
private void removeSlot0(net.minecraft.inventory.Slot slot, CallbackInfo c) | ||
{ | ||
length=this.inventoryItemStacks.size(); | ||
} | ||
|
||
@Inject(method = "removeSlot", at = @At(value = "TAIL"), require = 1, cancellable = false) | ||
|
||
private void removeSlot1(net.minecraft.inventory.Slot slot, CallbackInfo c) | ||
{ | ||
if(length!=this.inventoryItemStacks.size())return;//just in case it's fixed in future version | ||
this.inventoryItemStacks.remove(slot.slotNumber); | ||
// System.out.println( this.inventoryItemStacks); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package reobf.proghatches.oc; | ||
|
||
import java.util.Optional; | ||
|
||
import li.cil.oc.api.network.Message; | ||
import li.cil.oc.api.network.Node; | ||
import li.cil.oc.api.network.Visibility; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class TileCoprocessor extends TileEntity implements li.cil.oc.api.network.Environment{ | ||
Node node_ = li.cil.oc.api.Network.newNode(this, Visibility.Network) | ||
.withComponent("coprocessor") | ||
.create(); | ||
@Override | ||
public Node node() { | ||
|
||
return node_; | ||
} | ||
@Override | ||
public void writeToNBT(NBTTagCompound compound) { | ||
Optional.ofNullable(node_).ifPresent(s->s.save(compound)); | ||
super.writeToNBT(compound); | ||
} | ||
@Override | ||
public void readFromNBT(NBTTagCompound compound) { | ||
Optional.ofNullable(node_).ifPresent(s->s.load(compound)); | ||
super.readFromNBT(compound); | ||
} | ||
@Override | ||
public void onConnect(Node node) { | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void onDisconnect(Node node) { | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void onMessage(Message message) { | ||
|
||
|
||
} | ||
|
||
} |