Input P2P tunnels can now be assigned a new frequency. (#3765)

Shift right clicking an existing tunnel only allowed to copied the
stored frequency.

When shift right clicking now and the stored frequency being the same as
already stored one, it will now create a new one and save it to the memory
card. In other words doubling clicking will reset now, otherwise the old
behaviour is still kept.
This commit is contained in:
yueh
2018-10-21 11:17:01 +02:00
committed by GitHub
parent 0c88d1e7ee
commit 416c7d2683
5 changed files with 44 additions and 8 deletions
@@ -25,6 +25,7 @@ import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -174,6 +175,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
case SETTINGS_SAVED:
player.sendMessage( PlayerMessages.SavedSettings.get() );
break;
case SETTINGS_RESET:
player.sendMessage( PlayerMessages.ResetSettings.get() );
break;
default:
}
}
@@ -185,9 +189,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
{
if( !w.isRemote )
{
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
player.getHeldItem( hand ).setTagCompound( null );
this.clearCard( player, w, hand );
}
return EnumActionResult.SUCCESS;
}
@@ -197,9 +199,31 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
}
}
@Override
public ActionResult<ItemStack> onItemRightClick( World w, EntityPlayer player, EnumHand hand )
{
if( player.isSneaking() )
{
if( !w.isRemote )
{
this.clearCard( player, w, hand );
}
}
return super.onItemRightClick( w, player, hand );
}
@Override
public boolean doesSneakBypassUse( final ItemStack itemstack, final IBlockAccess world, final BlockPos pos, final EntityPlayer player )
{
return true;
}
private void clearCard( final EntityPlayer player, final World w, final EnumHand hand )
{
final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
player.getHeldItem( hand ).setTagCompound( null );
}
}