diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java index 2560bb2..7da5dd5 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/BufferedDualInputHatch.java @@ -35,10 +35,12 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; +import net.minecraftforge.oredict.OreDictionary; import com.google.common.collect.ImmutableList; import com.gtnewhorizons.modularui.api.ModularUITextures; @@ -66,7 +68,9 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; import gregtech.api.enums.SoundResource; +import gregtech.api.enums.ToolDictNames; import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -78,6 +82,7 @@ import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_TooltipDataCache.TooltipData; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gregtech.api.util.extensions.ArrayExt; import gregtech.common.tileentities.machines.IDualInputInventory; @@ -162,6 +167,7 @@ public List getExtraTooltip() { public NBTTagCompound writeToNBT(ItemStack is, NBTTagCompound tag) { is.writeToNBT(tag); tag.setInteger("ICount", is.stackSize); + return tag; } @@ -634,14 +640,15 @@ public static class CallerCheck { } } } -public boolean highEfficiencyMode(){return false;} +private boolean updateEveryTick; +public boolean updateEveryTick(){return updateEveryTick;} public boolean prevdirty; @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.getWorld().isRemote) return; - + dirty=dirty||updateEveryTick(); if(dirty){updateSlots();} dirty=dirty||getBaseMetaTileEntity().hasInventoryBeenModified(); //System.out.println(dirty); @@ -1100,6 +1107,7 @@ public void loadNBTData(NBTTagCompound aNBT) { .fromTag((NBTTagCompound) aNBT.getTag("BUFFER_" + ii)); } justHadNewItems = aNBT.getBoolean("justHadNewItems"); + updateEveryTick= aNBT.getBoolean("updateEveryTick"); super.loadNBTData(aNBT); } @@ -1114,6 +1122,7 @@ public void saveNBTData(NBTTagCompound aNBT) { .toTag()); aNBT.setBoolean("justHadNewItems", justHadNewItems); + aNBT.setBoolean("updateEveryTick",updateEveryTick); super.saveNBTData(aNBT); } @@ -1194,8 +1203,9 @@ public boolean justUpdated() { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Optional getFirstNonEmptyInventory() { - dirty=true;//IRecipeProcessingAwareHatch NOT working on dualhatch, so assume multi-te will consume items after calling this + public Optional getFirstNonEmptyInventory() { + dirty=true; + //IRecipeProcessingAwareHatch NOT working on dualhatch, so assume multi-te will consume items after calling this return (Optional) inv0.stream() .filter(not(DualInvBuffer::isEmpty)) .findAny(); @@ -1341,5 +1351,56 @@ public void updateSlots() { inv0.forEach(DualInvBuffer::updateSlots); super.updateSlots(); } - + +@Override +public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + BaseMetaTileEntity tile = (BaseMetaTileEntity) this.getBaseMetaTileEntity(); + if (tile.isServerSide()) { + if (!tile.privateAccess() || aPlayer.getDisplayName() + .equalsIgnoreCase(tile.getOwnerName())) { + final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null) { + boolean suc=false; + for(int id:OreDictionary.getOreIDs(tCurrentItem)){ + if(OreDictionary.getOreName(id).equals(ToolDictNames.craftingToolFile.toString())){ + suc=true;break; + }; + } + if(suc){ + GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); + GT_Utility.sendSoundToPlayers( + tile.getWorld(), + SoundResource.IC2_TOOLS_WRENCH, + 1.0F, + -1, + tile.getXCoord(), + tile.getYCoord(), + tile.getZCoord()); + updateEveryTick=!updateEveryTick; + + + GT_Utility + .sendChatToPlayer(aPlayer, + "updateEveryTick:"+updateEveryTick + ); + GT_Utility + .sendChatToPlayer(aPlayer, + StatCollector.translateToLocal("programmable_hatches.gt.updateEveryTick") + ); + + + + markDirty(); + return true; + } + + + } + } + } + + + + return super.onRightclick(aBaseMetaTileEntity, aPlayer); +} } diff --git a/src/main/resources/assets/proghatches/lang/en_US.lang b/src/main/resources/assets/proghatches/lang/en_US.lang index 4959194..273c838 100644 --- a/src/main/resources/assets/proghatches/lang/en_US.lang +++ b/src/main/resources/assets/proghatches/lang/en_US.lang @@ -176,3 +176,5 @@ tile.proghatches.peripheral_station.tooltip.3=Can only establish one-to-one conn tile.proghatches.peripheral_station.tooltip.4=Range:16 with no inter-dimension support tile.proghatches.peripheral_station.tooltip.5=Require no component channel. tile.proghatches.peripheral_station.tooltip=6 +programmable_hatches.gt.updateEveryTick=This mode is intended to force the check every tick when the hatch fails to work properly. Do not enable when unnecessary, for better server performance. + diff --git a/src/main/resources/assets/proghatches/lang/zh_CN.lang b/src/main/resources/assets/proghatches/lang/zh_CN.lang index 5dd432b..8fe02ab 100644 --- a/src/main/resources/assets/proghatches/lang/zh_CN.lang +++ b/src/main/resources/assets/proghatches/lang/zh_CN.lang @@ -186,3 +186,5 @@ tile.proghatches.peripheral_station.tooltip.2=只能和无线外设桥接卡建 tile.proghatches.peripheral_station.tooltip.3=距离:16格 无法跨维度 tile.proghatches.peripheral_station.tooltip.4=不占用组件数量 tile.proghatches.peripheral_station.tooltip=5 +programmable_hatches.gt.updateEveryTick=此模式用于每tick强制触发仓室的转移,以防(由于bug或某些corner case)转移过程未能正确触发 如果仓室工作正常,应该关闭此功能以优化服务器负载 +